Length and breadth of a rectangle are 5 and 7 respectively. Write a program to calculate the area and perimeter of the rectangle.
#include<iostream>intmain(){usingnamespacestd;cout<<"Area is "<<5*7<<endl;cout<<"Perimeter is "<<2*(5+7)<<endl;return0;}
2.
Write a program to input the value of the radius of a circle from keyboard and then calculate its perimeter and area.
#include<iostream>intmain(){usingnamespacestd;intradius;cout<<"Enter radius of circle"<<endl;cin>>radius;cout<<"Perimeter is "<<2*3.14*radius<<endl;cout<<"Area is "<<3.14*radius*radius<<endl;return0;}
3.
Write a program to enter a 4 digit number from the keyboard. Add 8 to the number and then divide it by 3. Now, the modulus of that number is taken with 5 and then multiply the resultant value by 5. Display the final result.
If the marks of Robert in three subjects are 78,45 and 62 respectively (each out of 100 ), write a program to calculate his total marks and percentage marks.
9.
Write a program to enter the values of two variables from the keyboard and then interchange the values of the two variables. E.g.-
If entered value of x is 5 and y is 10 then
cout <<x << " and " << y
should print 10 and 5.
#include<iostream>intmain(){usingnamespacestd;intx,y,temp;cin>>x;cin>>y;temp=x;//temp is assigned the value of xx=y;//x is assigned the value of yy=temp;cout<<x<<" and "<<y<<endl;return0;}
10.
Take input of some length in meter and covert it to feet and inches.
11.
Write a program to convert Fahrenheit into Celsius.
12.
The total number of students in a class are 45 out of which 25 are boys. If 80% of the total students secured grade 'A' out of which 17 are boys, then write a program to calculate the total number of girls getting grade 'A'.
#include<iostream>intmain(){usingnamespacestd;inttotal,b,g;b=17;total=(80*45)/100;//total students getting grade Ag=total-b;//number of girls getting grade Acout<<"Number of girls getting grade A = "<<g<<endl;return0;}
Level 2
1.
Write a program to calculate the sum of the first and the second last digit of a 5 digit.
E.g.- NUMBER : 12345 OUTPUT : 1+4=5
#include<iostream>intmain(){usingnamespacestd;intn,first,second,third,forth,fifth,sum;n=23462;/*Now we will take out each digit of this number and then finally add the first and the second last digits*/first=n/10000;//first digitn=n%10000;second=n/1000;//second digitn=n%1000;third=n/100;//third digitn=n%100;forth=n/10;//forth digitfifth=n%10;//fifth digitsum=first+forth;cout<<"sum : "<<sum<<endl;return0;}
2.
Take a 4 digit number. Write a program to display a number whose digits are 2 greater than the corresponding digits of the number TAKEN.
For example, if the number which was taken is 5696, then the displayed number should be 7818.
3.
Write a program to calculate the sum of the digits of a 3-digit number.
Number : 132
Output : 6
4.
Write a program to reverse a 3-digit number. E.g.- Number : 132 Output : 231