C++ Exercise
C++ Exercise
FACULTY OF SCIENCE
Computer 1(COMP101)
Exercise
1. Write a C++ program that reads the number of minutes and seconds, then
converts them to the correct fraction of an hour, and displays it. For example,
37 minutes and 30 seconds is 0.625 of an hour.
2. Write a C++ Program to Swap Two Numbers with and without using third variable.
3. Write a C++ Program to convert inches to feet, yards and inches.
For example
Enter Inches to Convert ::500
After Conversion from inches to feet, yards and inches::
Yards = 1
Feet = 5
Inches = 8
4. Write a C++ Program to Convert Days Into Years Weeks and Days.
For example
Enter No. of days :: 1234
No. of Years: : 3
No. of Weeks :: 19
No. of Days :: 6
5. Write a C++ program which input principal, rate and time (p, r, t) from user and
calculate compound interest. The compound Interest is an interest that obtain by
adding the interest of each year to the principal sum and then calculating the interest
on the updated amount.
CI = P(1+R/100)T – P
6. Write a C++ program that reads the meal cost for a customer, the tax percentage and
the tip percentage, then computes the tax on the given meal cost, and the tip on the
total after adding the tax. Finally, the program displays the meal cost, tax amount, tip
amount, and total bill on the screen.
Run your program with the following input:
Meal cost: $44.50
Tax: 6.75 %
Tip: 15 %