Practice Programs
Practice Programs
Q1. Write a program that asks the user to type 5 integers and writes the average of the
5 integers.
Q2. Write a program that asks the user to accept amount and discount from the user
then display the payed amount.
HINT:
dis_amonut= (discont/100)*amount
Q3. Accept two entry and then display arithmetic operation (+,-,*, /, %).
Q4. Accept the values in meter then display in inches and centimeters.
HINT:
1m = 39.370079 inches
1 meter (m) = 100 centimeters (cm)
Q5. Accept the values in GB and display the value in bytes.
HINT:
1 GB=1024*1024*1024 bytes
Q6. Write a program that asks the user to type the width and the length of a rectangle
and then outputs to the screen the area and the perimeter of that rectangle
HINT:
area=width*length
perimeter=2*(width+length)
Q7. Write a program which accept temperature in Fahrenheit and print it in centigrade
HINT:
5*(F-32)/9
Q8. Write a program which accepts a character and display its next character.
Q9. Write a program to swap the values of two variables
Q10. Write a program to swap value of two variables without using third variable
Q11. What is the output of following program?
int result = 4 + 5 * 6 + 2;
cout<<result;
int a = 5 + 7 % 2;
cout<<a;
Q12. Write a program which accepts days as integer and display total number of years,
months and days in it.
For example: If user input as 856 days the output should be 2 years 4 months 6 days.
Q13. Accept 5 digits no from the user then display following option.
No=12345
Result =15