You are on page 1of 3

LAB NO.

4
 Objectives
1. Arithmetic Operations
2. Assignment Operators

Task No. 01 :
Write a C++ code to evaluate the following expression
1. where p=2, r=1, q=6, w=3.3, x=9.3, y=4.5
2. Source Code :
3. #include <iostream>
4. using namespace std;
5. int main()
6. {
7. int z;
8. int p=6 , r=1, q=2, w=4, x=3, y=5 ;
9. z=p*r%q+w/x-y;
10.cout<<z;
11.return 0;
12.}

Output Result :
Task NO 02 :
Taking “float” and “char” datatype as input variable
Source Code :
1. #include<iostream>
2. using namespace std;
3. int main()
4. {
5. float a;
6. char s;
7. cout<<"Enter the float value = ";
8. cin>>a;
9. cout<<"Enter the character = ";
10.cin>>s;
11.cout<<"The float is " <<a<<" and "<<" the character is "<<s<<endl;
12.return 0;
13.}
Output Result :
Task NO. 3 :
Write a
code to
1. get the
length
“L” as a
float
number
2. compute
and
display
the area
of a square with side length “L”
3. compute and display the volume of a cube with side length “L
Source Code :
1. #include <iostream>
2. using namespace std;
3. int main() //function main begins program execution
4. {
5. float a, l;
6. cout << "Enter the side of square:";
7. cin >> l;
8. a = l * l;
9. cout << "Area of Square: " << a << endl;
10.return 0;
11.}
Out Put Result :

You might also like