PF-I (Lab) Assignment # 1: The University of Lahore, CS&IT Department
PF-I (Lab) Assignment # 1: The University of Lahore, CS&IT Department
PF-I (Lab)
Assignment # 1
Start Date: 26-07-2020 Section: B Total Marks: 10
Task 1:
Write a program to find the value of distance D for given values of x, v, t, a.
Take the input of above variables from user.
Where D= x + vt + 1/2at2
Task 2:
Take 3 numbers from user and display their average.
Task 3:
Write a program which take any number from user and display the square of that
number.
Task 4:
Write a program which can print the following shape according to the user input (Using
variable).
For example, if the user enters 3, the output must be like given below.
Sample Output:
Task 5:
Dry run the code and write the output. (Do not use compiler)
Code: Output:
int a,b,c;
a=6,b=8;
c= --b + a;
cout<<"c= "<<c<<endl;
a= 2 * c + a++;
cout<<"a= "<<a<<endl;
b= b++ + ++c + a;
cout<<"b= "<<b<<endl;
Task 6:
Dry run the code and write the output. (Do not use compiler)
Code:
int a , b,d;
char c;
a = 4, b = 3;
c = 'S';
d = a + b + c;
cout<<"d="<<d<<endl;
c += b;
cout<<"c="<<c<<endl;
b +=2 * c - --a;
cout<<"b="<<b<<endl;
a *= 2 * b + c;
cout<<"a="<<a<<endl;
a = b-- * 3;
cout<<"a="<<a<<endl;