0% found this document useful (0 votes)
27 views2 pages

PF-I (Lab) Assignment # 1: The University of Lahore, CS&IT Department

The document contains instructions for 6 programming tasks. Task 1 requires writing a program to calculate distance given values for x, v, t, and a. Task 2 requires taking 3 numbers from the user and displaying their average. Task 3 requires writing a program to display the square of a number entered by the user. Task 4 requires writing a program to print a shape based on a number entered by the user. Tasks 5 and 6 require dry running code snippets and writing the output without using a compiler.

Uploaded by

Hamza Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

PF-I (Lab) Assignment # 1: The University of Lahore, CS&IT Department

The document contains instructions for 6 programming tasks. Task 1 requires writing a program to calculate distance given values for x, v, t, and a. Task 2 requires taking 3 numbers from the user and displaying their average. Task 3 requires writing a program to display the square of a number entered by the user. Task 4 requires writing a program to print a shape based on a number entered by the user. Tasks 5 and 6 require dry running code snippets and writing the output without using a compiler.

Uploaded by

Hamza Niazi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

The University of Lahore, CS&IT Department

PF-I (Lab)
Assignment # 1
Start Date: 26-07-2020 Section: B Total Marks: 10

Due Date:02-08-2020 Program: BSCS

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;

You might also like