Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Programming Fundamentals

Assignment # 1
Due Date: 18-January-2023
You are required to submit a zip following the naming convention RollNo_Assignment_1_PF.
Each and every question should have naming RollNo_q1.cpp. You have to submit only .cpp in a
zip along with hard copy of assignment containg all questions. Failing to do so will cause you to
lose 30% of your marks. Plagiarism is strongly discouraged you will be marked 0 in this
assignment and also a 50% reduction in a previous assignment. Commenting, the proper naming
convention has marks so do follow the naming convention, proper indentation, and comment on
your code.

Task 1:
A set of linear equations:
aX + bY = c
dX + eY = f
can be solved using Cramer's rule as:
X = (ce - bf)/(ae - bd) Y = (af - cd)/(ae - bd)
Design a flowchart to read in a, b, c, d, e and f and then solve for X and Y.

Task 2:
Suppose a, b, and c are int variables and a = 5 and b = 6. What value is assigned to each variable
after each statement executes? If a variable is undefined at a particular statement, report UND
(undefined)

Task 3:
Write the following compound statements as equivalent simple statements
a. x += 5 - z;
b. y *= 2 *x + 5 - z;
c. w += 2 *z + 4;
d. x -= z + y - t;
e. sum += num;
Task 4:
Suppose x and y are int variables and z is a double variable. Assume the following
input data:
37 86.56 32
What value (if any) is assigned to x, y, and z after each of the following statements
executes? (Use the same input for each statement.)
a. cin >> x >> y >> z;

b. cin >> x >> z >> y;

c. cin >> z >> x >> y


Task 5:
The following program has syntax errors. Correct them. On each successive line,
assume that any preceding error has been corrected.
#include <iostream>
using namespace std;
int main()
{
int temp;
string first;
cout << "Enter first name: ;
cin >> first
cout << endl;
cout << "Enter last name: ;
cin >> last;
cout << endl;
cout << "Enter today's temperature: ";
cin >> temperature;
cout << endl;
cout << first << " " << last << today's temperature is: ";
<< temperature << endl;
return 0;
}

Task 6:
Get gender, year of service and qualification of employee as input from keyboard and determine
his/her salary based on following chart
Gender Year of service Qualification salary
Male >=10 P 15000
>=10 G 12000
<10 P 10000
<10 G 7000
Female >=10 P 12000
>=10 G 10000
<10 P 7000
<10 G 6000
Task 7:
Suppose you give a dinner party for six guests, but your table seats only four. In how Many ways
can four of the six guests arrange themselves at the table? Any of the six Guests can sit in the
first chair. Any of the remaining five can sit in the second chair. Any of the remaining four can
sit in the third chair, and any of the remaining three can sit in the fourth chair. (The last two will
have to stand.) So the number of possible arrangements of six guests in four chairs is 6*5*4*3,
which is 360. Write a program that calculates the number of possible arrangements for any
number of guests and any number of Chairs. (Assume there will never be fewer guests than
chairs.) Don’t let this get too complicated. A simple for loop should do it.

You might also like