You are on page 1of 2

C++ Programming exercises set 1 – Very basic Programs

1. Assume that there are 7481 gallons in a cubic feet. Write a program that asks the user to enter
the number of gallons and displays the equivalent in cubic feet.

2. Write an application that inputs three integers from the user and displays the sum, average,
product, smallest and largest of the numbers. [Note: The calculation of the average in this
exercise should result in an integer representation of the average. So if the sum of the values is
7, the average should be 2, not 2.3333....]

3. Write an application that reads five integers, determines and prints the largest and smallest
integers in the group.

4. Write an application that reads an integer and determines and prints whether it is odd or even.
[Hint: Use the remainder operator. An even number is a multiple of 2. Any multiple of 2 leaves
a remainder of 0 when divided by 2.]

5. Write an application that reads two integers, determines whether the first is a multiple of the
second and prints the result. [Hint : Use the remainder operator.]

6. Write an application that calculates the squares and cubes of the numbers from 0 to 10 and
prints the resulting values in table format, as shown below. [Note: This program does not
require any input from the user.]

7. Write an application that inputs one number consisting of five digits from the user, separates the
number into its individual digits and prints the digits separated from one another by three spaces
each. For example, if the user types in the number 42339, the program should print 4,2,3,3,9

8. Write a program to find the sum of following harmonic series for a given value of N. [1 + ½ +
1/3 + ¼ + 1/5 …........................ 1/N] (Value of N should be taken as user input)

9. Write a program to convert the given temperature in Fahrenheit to Celsius using [C = (F-
32)/1.8] Display the values in tabular form.

10. The straight line method of computing the yearly depreciation of the value of an item is given
by [Depreciation = (Purchase price – Salvage value)/Years of service]. Write a program to
determine the salvage value of an item when the purchase price, years of service and the annual
depreciation is given.

11. Given a number , write a program using WHILE loop to reverse the digit of the number. For
example 12345 should be written as 54321.

12. Write a program to compute the sum of the digits of given integer number.

13. Write a program using DO-WHILE loop to calculate and print the Fibonacci series upto the Nth
number. Take N as input from user.

14. Write a program to compute the factorial of a given number M. (Taken as input from the user).
15. Write a program to write a function to swap two integers using call by value and test it from
main function.

16. Write a program to write a function to swap two integers using call by pointer and test it from
main function.

17. Write a program to write a function to swap two integers using call by reference and test it from
main function.

18. Admission to a professional course is subject to the following condition


1. Marks in mathematics >=60
2. Marks in physics >=50
3. Marks in chemistry >=40
4. Total marks in all three subjects >=200 OR total marks in maths and physics >=150
Given the marks in three subjects write a program to process the application to find out the
eligibility.

You might also like