Lab 2.
Lab 2.
Lab 2.
033
10 * (24 / ( 5 – 2 ) ) + 13
1 (5-2) 10*(24/(3))+13
2 (24/3) 10*(24/3)+13
3 10*8 10*8+13
4 80+13 80+13
Result: 93
2.1.2. Program No 2
Write a program to determine the value of following expression, where a =1.5, b=1.1, c=2.89, d=9.0
2d+4ab*c+5a
Code of Program No 2:
E:\usman.exe
2.1.3. Program No 3
Write a program to calculate and print the area of a square.
E:\usman.exe
2.1.4. Program No 4
Write a program in C++, which takes radius from the user and calculate the area of sphere i.e.
Area= 4pr2
Hint p=3.1416
Area= 4*3.1416*r*r
E:\usman.exe
2.1.5. Program No 5
Write a program that include limits header file, and show the max and min limits of all data types.
E:\usman.exe
2.1.6. Program No 6
Write a program to find number of bytes occupied by various data types using the sizeof operator. int
2.1.7. Program No 7
A += 10 A=A+10
A-= 10 A=A-10
A *= 10 A=A*10
A /= 10 A=A/10
A %= 10 A=A%10
2.1.8. Program No 8
Write a C++ program that declares and initializes two-character variables. Add the characters and display
their result.
2.1.9. Program No 9
Write a C++ program that declares two integer variables, two-character variables. Initializes the integer
variables, and assign the integer variables to character variables. Display the character variables. Also,
display the size of all variables using the size of operator.
E:\usman.exe
2.1.10. Program No 10
Write a Program in C++ that declares and initializes an integer variable. Increment and decrement the
variable by 5 using compound assignment. Then multiply and divide the variable by 2 using compound
assignment. Display the result at every level. Use auto keyword to declare the variable.
E:\usman.exe