C++ Questions
C++ Questions
Input / Output
1. WAP to print the square and cube of a given number.
2. WAP to convert the given number of days into years and months.
3. WAP to convert the given number of days into weeks and months.
4. WAP to convert the given number of seconds to Hours and Minutes.
5. WAP to find the area of a triangle on a given base length and height. Also calculate the area for a circle
on a given diameter.
6. WAP to input a student’s marks obtained out of 300 and prints the percentage marks.
7. WAP to convert the temp from Centigrade to Fahrenheit. C/5= [F-32]/9.
8. WAP to calculate the number of HCF of a number. If the LCM and product of the number are given.
9. WAP to calculate the numbers of dresses one can make from a given length of cloth. If each dress takes
5 meters of cloth.
10. WAP to accept height in centimeters and then converts the height to feet and inches. [1 foot =12 inches,
1 inch=2.54 cm].
11. WAP to print the ASCII code for a given digit.
12. WAP to accept a character between a to j and print next 4 characters.
13. WAP to convert the given number of days into years, weeks and days.
14. WAP to find the result of the expression x2+4x+4 for a given value of x.
15. WAP to calculate the values of the expression (m*n)/(x+y) for given values of m, n, x and y.
16. WAP to print the sum of all numbers till a values specified by the user. [n[n+1]]/2.
17. WAP to calculate the Simple Interest & Compound Interest on given amount, rate and time.
18. WAP to read a number n and print n2, n3, n4 and n5.
19. WAP to find the area of a triangle.
20. WAP to accept marks of five subjects and print their percentage.
21. WAP to find the number of rectangular boards, which can be made from a bigger board of given
dimension. Each rectangle board has area of 4 cm 2.
22. WAP to find the area in which cow grazes. If it is tied on a rope of given length.
23. A boy throws a stone horizontally with a given speed and acceleration. Find the final velocity of the
stone after time 5 sec.
24. Accept three numbers and display the remainder of the sum of that number with 2.
25. WAP to read two numbers and print their quotient and remainder.
26. A shopkeeper offer 10% discount on the purchase. Accept the price and quantity and display the
amount payable.
27. Accept two numbers and interchange their values.
28. Accept basic salary on an employee and display DA, HRA, PF, GROSS and Net Amount. Where
DA=2% of Basic salary, HRA=5% of Basic Salary, Gross=Basic + DA + HRA, PF=12% of Gross and Net
Amount=GROSS-PF.
29. WAP to display the result of the following expression using library function math.h
a. 2-ye2y+4y b. (p+q)/(r+s)4 c. square root(a2+b2+c2)
Conditional Statement
1. WAP to check whether the person is eligible to vote or not.
2. WAP to find whether a person is rich or poor by his salary. If the salary is less then equal to 3000
consider him POOR else RICH.
3. WAP to find whether a person will get commission or not on his sales .If the sales is greater than
50000 then he receives a commission.
4. WAP to find whether a number is Even or Odd.
5. WAP to find whether a number is Negative or positive.
6. WAP to find whether a year is Leap year or not.
7. WAP to find the greatest no. between has given two numbers.
8. WAP to input a number. If the number is odd positive, print the square root otherwise print n 5.
9. WAP to input a number. if the number is even, print its square otherwise print its cube.
10. WAP to input choice [1 or 2].if choice is1, print the area of a circle otherwise print the perimeter of
circle. Accept the radius of circle from user.
11. WAP to input principle amount and time. It time is more than 10 yrs, calculate the simple interest
with rate 8%, otherwise calculate it with rate 12% per annum.
12. WAP for temperature conversion from Fahrenheit to Celsius or Celsius to Fahrenheit according the
users choice.
13. WAP to find whether a person has made profit loss. If the cost price and selling price of an article is
given. Also display the profit or Loss.
14. WAP to find the type of whether on a given day. If the temperature is less than 20 it is cold. If the
temperature is greater than 40 it is hot day temperature is between 20 to 40 is normal day.
15. WAP to find the whether a person is below weight, normal weight or above weight. If the weight is
less than 40 it below weight is above 80 it is above weight, and if the weight is between to 80 is
normal weight.
16. WAP to find the whether student has pass or not. If marks of three subject are given. If the
percentage is greater than 40 and the student is disciplined [D] than the student has passed.
17. WAP to find the whether a person is eligible for driving license or not on the following condition. If
the person age is greater than eyesight is good [G] then he/she is granted the license.
18. WAP to find whether a student has passed or not. If marks of three subjects are given. Also
provided the margin of failure if the student fails.
19. WAP to find whether a person is child, teen, youth or old depending on his/her age on the following
condition.
Age Person
<14 Child
14-20 Teen
21-50 Youth
>50 Old
20. WAP to find the result of a student on the following condition.
Marks Division
<40% Fail
>=40% to <50% Third
>=50% to <60% Second
>=60% to <100% First
21. WAP to calculate commission for the salesmen. The commission is calculated according to the
following rates:
Sales Commission rate
30001 onwards 15%
22001 to 30000 10%
12001 to 22000 7%
5001 to 12000 3%
0 to 5000 0%
22. WAP to find the greatest no. between has given three nos.
23. WAP to find the sum of greatest no. and lowest no. between has given three nos.
24. WAP to find the type of triangle [Equilateral, Isosceles or Scalene] from has given three angles.
25. WAP to accept the marks obtained by a student in Physics, Chemistry & Math. Display the grade on
the following condition.
Condition Grade
Above 50 in all three subjects A
Above 50 in any two subjects B
Above 50 in any one subjects C
Below 50 in all three subjects D
26. WAP to find the roots of the Quadratic Equation ax2+bx+4=0, where a, b, c are the co-efficient of
the quadratic equation. Also indicate if the roots are Real, Imaginary, Complex or Equal.
27. WAP to find whether the given character is a digit or a letter or any other character.
28. WAP to print whether a given character is an uppercase or a lowercase vowels or any other
character.
29. WAP to accept three numbers and display the numbers in ascending order.
30. WAP to accept two numbers and an operator and display the correspondence result.
Switch Statement
1. Make the following menu
Menu
1. Hello
2. Welcome
3. Bye – Bye
4. Sayonara
2. Arithmetic Operation
1. Add
2. Subtract
3. Multiply
4. Divide
5. Reminder
3. Temperature Conversion
1. Centigrade to Fahrenheit
2. Fahrenheit to Centigrade
4. Length Conversion [accept length in cm]
1. Inch
2. Feet
3. Meter
5. Area
1. Triangle
2. Square
3. Circle
4. Rectangle
6. Program to input number of week’s day [1-7] and translate to its equivalent of the day of the week [e.g. 1
to Sunday, 2 to Monday …… 7 to Saturday]
7. Input two operands and an operator and then display the calculate result.
5 * * ********* 1 1 1234554321
45 ** ** **** **** 12 21 1234 4321
345 *** *** *** *** 123 321 123 321
2345 **** **** ** ** 1234 4321 12 21
12345 ********* * * 12345 54321 1 1
* * * ********* 1 1 1234554321
** ** ** **** **** 12 21 1234 4321
*** *** *** *** *** 123 321 123 321
**** **** **** ** ** 1234 4321 12 21
***** ********* * * 1234554321 1 1
**** **** **** ** ** 1234 4321 12 21
*** *** *** *** *** 123 321 123 321
** ** ** **** **** 12 21 1234 4321
* * * ********* 1 1 12345 54321
String Array
1. WAP to accept a name and display the same.
2. WAP to accept five names and display the same.
3. WAP to accept a string and find the length of the string.
4. WAP to accept a string and reverse the string,
5. WAP to accept a string in lower case and display the string in upper case.
6. WAP to accept a string in upper case and display the string in lower case.
7. WAP to accept a string and display the string in toggle case.
8. WAP to concatenate the two strings.
9. WAP to compare two strings.
10. WAP to display the given string is Palindrome or not.
11. WAP to count a number of characters appears in the string.
12. WAP to accept a string and a character and replace that character with ‘#’.
13. WAP to insert a character in a given position of a string.
14. WAP to delete a character in a given position of a string.
15. WAP to delete all duplicate character present in a string.
16. WAP to display the given string in Alphabetical order [Ascending order].
17. WAP to display the given string in Alphabetical order [Descending order].
18. WAP to find the character occurs maximum times in a string.
19. WAP to find the frequency of each element present in a string.
20. WAP to find the number of vowels and consonants present in a string.
21. WAP to find the number of character present in a sentence.
22. WAP to find the number of words present in a sentence.
23. WAP to fill the unused spaces in a sentence by # sign.
24. WAP to reverse all strings stored in an array.
25. WAP to reverse all words present in a sentence.
26. WAP to find the occurrence of string into another string.
27. WAP to find the position of a string inside another string.
28. WAP to display the biggest word in a sentence.
Function
Function has no arguments and no return type
1. WAP to make a function to print your name.
2. WAP to make a function to print your name five times.
3. WAP to make a function to display 1st 10 natural numbers.
4. WAP to make a function to display the sum of 1 st 10 even numbers.
5. WAP to make a function to display all prime nos. presents between 1 – 100.
6. WAP to make a function to display all twine primes presents between 1 – 100.