Pool of Questions Programming in C++ (10 x 3 = 30 questions)
1. Input three numbers and find the largest
2. Input a group code and display the corresponding group name based on the following:
5, 7 – Science (Computer Science)
33, 34 – Humanities (Computer Applications)
39 – Commerce (Computer Applications) Other codes – Non Computer groups
3. Input three numbers and find the difference between the smallest and the largest numbers.
4. Input a day and display the corresponding day name of the week using switch statement.
5. Assume that January 1 is Monday. Write a program using switch to display the name of the
day in that month when we input day number.
6. Find the amount to be paid for the consumption of electricity when the previous and current
meter-readings are given as input based on the conditions given in the table.
Units consumed Amount per Unit
Up to 100 Rs. 0.50/-
101 - 150 Rs. 0.75/-
151 - 200 Rs. 1.00/-
201 - 250 Rs. 1.50/-
Above 250 Rs. 2.00/-
7. Input the three coefficients of a quadratic equation and find the roots.
8. Find area of a rectangle, a circle and a triangle. Use switch statement for selecting an option
from a menu.
9. Find all prime numbers below 100.
10. Find the sum of the digits of an integer number.
11. Find the sum of the squares of the first N natural numbers.
12. Display the first N terms of Fibonacci series.
13. Input two years (e.g. 1000, 2000) and display all leap years between them.
14. Input a number and check whether it is palindrome or not.
15. Read N numbers into an array and display the numbers larger than the average value.
16. Display Pascal’s triangle having N rows.
17. Find the length of a string without using strlen() function.
18. Create an array of N numbers and find the largest.
19. Read admission number of N students in a class and search for a given admission number in
the list. Use linear search method of searching.
20. Create an array to store the heights of some students and sort the values.
21. Create a square matrix and display the same in matrix form. Find the sum of leading diagonal
elements (from top left to bottom right) and off diagonal elements (top right to bottom left)
separately.
22. Find the factorial of a number with the help of a user-defined function.
23. Define a function to find the factorial of a number. Using this function find the value of nCr.
24. Input an integer number and display its binary equivalent with the help of a user-defined
function.
25. Define a function to swap the contents of the two variables. Using this function, interchange
the values of three variables. E.g. AàBCàA.
26. Find the sum of the first N natural numbers using recursive function.
27. Define a function to accept an integer number and return its reverse (e.g. if the argument is
123 the return-value should be 321). Using this function display all palindrome numbers
between a given range.
28. Find the net salary of an employee by defining a structure with the details Employee Code,
Name, Basic Pay, DA, HRA and PF.
29. With the help of a structure, develop a C++ program to read register number, name, and
Scores obtained (out of 200) in English, second language, chemistry, physics, computer
science and mathematics by 5 students. Calculate total score, average score and grade
obtained by them. Grade is calculated based on the average as given in the table. Display
register number, name, average score and grade of these students.
Average Score Grade
>=180 A+
>=160 A
>=140 B+
>=120 B
>=100 C+
>=80 C
>=60 D+
<60 No Grade
30. Define a structure to store the details of books such as Book Code, Book Title, Date of
Purchase, Author, Publisher and Price. Write a program with this structure to store the
details of 10 books and display the details.
31. Create two pointers, initialise with two numbers and find the sum and average of these
numbers.
32. Input string into a character pointer and count the vowels in the string.
33. Create a dynamic array to store the names of a group of students and prepare a roll list
according to the alphabetical order of the names.