0% found this document useful (0 votes)
9 views

C++ Questions

c++ questions

Uploaded by

Manas Ranjan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

C++ Questions

c++ questions

Uploaded by

Manas Ranjan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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)

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
1
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
2
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
3
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
4
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

Looping / Iteration statement:


1. WAP to print your name five times.
2. WAP to print the natural nos. between 1 to 20.
3. WAP to print the natural nos. between 1 to n.
4. WAP to print the even numbers between 1 to 20.
5. WAP to print the odd numbers between 1 to 20.
6. WAP to print the sum of all even numbers between 1 to 20.
7. WAP to print the sum of all odd numbers between 1 to 20.
8. WAP to print the sum of all even and odd numbers separately between 1 to 20.
9. WAP to print the sum of all even and odd numbers separately between a given ranges.
10. WAP to print the ASCII set of computer.
11. WAP to print the Multiplication table of a given no. in the following form.
Input n=2
2X1=2
2X2=4
2X3=6
…………
………..
2 X 10 = 20
12. Display the following series
a. 1, 4, 9, 16, 25 ……………….. 100
b. 1, 8, 27, 64, 125, …………… 1000
c. 100, 81, 64, 49 ……………….1
d. 1, 2, 4, 5, 7……………………..n
e. 1.4.7.10………………………...n
f. 5, 10,20,25,35 ………………….n
g. 0,1,1,2,3,5,8 …………………...n
h. 0, 7, 26, 63 ……………………n
i. 1, 2, 4,8,16 ………………………n
j. 1, 10, 2, 9, 3, 8………………….10, 1
k. 1, 11,111,1111,11111 …………n
l. 1,12,123,1234 ………………….n
13. WAP to find the sum of five nos. given by the user.
14. WAP to accept the age of n employees and count how many persons
are child, teen, youth and old.
15. WAP to find the sum and average temperature of a week. If the user
input the daily temperature.
16. WAP to accept 5 numbers and display the largest no.
17. WAP to accept n numbers and display the sum of largest & lowest no.
18. WAP to print the largest even and lowest odd numbers from a list of n
numbers.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
5
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

19. WAP to find the Factorial value of a number.


20. WAP to print the factors of a number.
21. WAP to check whether a number is Prime or not.
22. WAP to print the individual digit of a number.
23. WAP to print the reveres of a number.
24. WAP to print the largest digit of a number.
25. WAP to print the sum of individual digit of a number.
26. WAP to print the sum of largest & lowest digit of a number,
27. WAP to check number is Palindrome or not.
28. WAP to check number is Armstrong or not.
29. WAP to check number is Automorphic or not.
30. WAP to check number is Perfect or not.
31. WAP to generate the Prime numbers between 1 to 1000.
32. WAP to generate the Palindrome numbers between 1 to 1000.
33. WAP to generate the Armstrong numbers between 1 to 1000.
34. WAP to generate the Automorphic numbers between 1 to 1000.
35. WAP to generate the Perfect numbers between 1 to 1000.
36. WAP to display the Prime-Factors of the number.
37. WAP to find the number of people eligible to vote in a colony.
38. WAP to display all the Pythagorean triplets in the range or 100 to
1000.
39. WAP to convert the given Octal no. to its Decimal equivalent.
40. WAP to convert the given Binary no. to its Decimal equivalent.
41. WAP to generate the following series.
a. 1+X+X2+X3+X4+………..+XN
b. 1+1/1!+1/2!+1/3!...............+1/N!
c. X/1!+X/2!+X/3!+…………..+X/N!
d. 1+X2/2!+X3/3!+…………..+XN/N!
e. X-X2/2!+X3/3!-X4/4!.........+XN/N!

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
6
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

42. WAP to generate the following patterns.


* 1 1 1 5 5 A A
** 12 22 21 45 54 AB BA
*** 123 33 321 345 543 ABC CBA
**** 1234 4444 4321 2345 5432 ABCD DCBA
***** 12345 55555 54321 12345 54321 ABCDE EDCBA

E 1 ***** 12345 54321 55555 54321 12345


DD 23 **** 1234 4321 4444 5432 2345
CCC 345 *** 123 321 333 543 345
BBBB 4567 ** 12 21 22 54 45
DDDDD 56789 * 1 1 1 5 5
ABCDE EDCBA ABCDE EDCBA EEEEE 12345 12345 1
ABCD DCBA BCDE EDCB DDDD 1234 2345 12
ABC CBA CDE EDC CCC 123 345 123
AB BA DE ED BB 12 45 1234
A A E E A 1 5 12345

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

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
7
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

Array [Single Dimensional]


1. WAP to store the marks of 10 students in an array and display the same.
2. WAP to input the monthly salary of 10 employees and find the number of employees earning above
5000 salaries.
3. WAP to store the marks of 5 subjects of a student and display the total and average marks.
4. WAP to store 10 numbers in an array and display all the even nos. present in the array.
5. WAP to store 10 numbers in an array and display all the nos. present in the odd pockets.
6. WAP to display the sum of all even & odd nos. separately stored in an array.
7. WAP to find the largest and lowest element present in an array.
8. WAP to store 5 nos. in one array, 5 numbers in another array and display the sum of both array
elements.
9. An array EMP [20] contains the number of employees joined in different years. WAP to find the number
of years in which no employee joined.
10. WAP to search an element in an array using Liner Search.
11. WAP to search an element in an array using Binary Search.
12. WAP to insert a number into a given position of an array.
13. WAP to delete a number into a given position from an array.
14. WAP to delete duplicate elements from an array.
15. WAP to display the table of every nos. stored in the array.
16. WAP to arrange the array in such a way that all even pockets of the array contains odd numbers starting
from 15 and all odd pockets should contains even nos. starting from 10.
A [0] =15
A [1] =10
A [2] =17
A [3] =12
……….
……….
A [8] =23
A [9] =18
17. Sorting
a. Selection Sort
b. Bubble Sort
c. Insertion Sort
d. Merger Sort

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
8
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

18. Matrix [double dimensional array]


a. Accept elements in 3x3 matrix and display elements in the matrix form.
b. Accept elements in 3x3 matrix and display the sum of all elements present in the matrix.
c. Accept elements in 3x3 matrix and display the sum of ro2 elements.
d. Accept elements in 3x3 matrix and display the sum of column elements.
e. Accept elements in 3x3 matrix and display the sum of both the diagonals elements.
f. Accept elements in 3x3 matrix and display the transpose matrix.
g. Accept elements in 3x3 matrix and display the mirror matrix.
h. Accept elements in 3x3 matrix and display the largest element present in each row.
i. Accept elements in 3x3 matrix and display the largest element present in each column.
j. WAP to check the equality of two matrixes.
k. WAP to find the sum of two matrixes.
l. WAP to find the difference of two matrixes.
m. WAP to find the product of two matrixes.
n. WAP to read the sales of 3 salesmen in 4 months and print the total sales made by each
salesman.
o. WAP to read the sales of 3 salesmen in 4 months and print the details of the sales man who
got the highest sale.
p. WAP to calculate the total, average marks and grade of 5 students form 3 test score.
q. WAP to read the daily maximum temperature recorded in 10 cities in a week and display the
city and day corresponding to
i. The highest temperature
ii. The lowest temperature

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
9
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
10
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

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.

Function has no arguments but return type


7. WAP to make a function to display the sum of 1 st 10 odd numbers.
8. WAP to make a function to find the sum of square of odd number 10 terms.

Function has arguments but no return type.


9. WAP to make a function to swap the data of two variables.
10. WAP to make a function to display the Fibonacci series up to nth term.
11. WAP to make a function to display all the primes’ nos. present in an array.
12. WAP to make a function to display the tables of all the nos. present in an array.
13. WAP to make a function that takes two arguments a character and an integer and prints the character
given number of times. If however the integer is missing the function prints the character twice.
14. WAP to make a function to display the element of a vector in a sorted list.
15. WAP to make a function to display the transpose of a matrix.
16. WAP to make a function to display the addition, subtraction & multiplication of the matrixes according to
the user choice.
17. WAP to make a function to concatenation of two strings.
18. WAP to make a function to count the no. of vowels, consonants and word present in a sentence.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
11
GURUKUL INSTITUTE OF MANAGEMENT & INFORMATION TECHNOLOGY

Functions have arguments and also return type


19. WAP to make a function to take two integers and an arithmetic operator and print the corresponding
result.
20. WAP to make a function to convert inches to feet.
21. WAP to make a function to find the simples Interest. If principle rate and time are given.
22. WAP to make a function to find the sum of natural number of a given range.
23. WAP to make a function to find the value raised to another number.
24. WAP to make a function to find the GCD [Greatest Common Divisor] of two numbers.
25. WAP to make a function to find the LCM [Lowest Common Multiplication] of two numbers.
26. WAP to make a function to find the factorial of a number.
27. WAP to make a function to display the given number is prime or not.
28. WAP to make a function to display the given number is Palindrome or not.
29. WAP to make a function to display the sum of individual digits of a number.
30. WAP to make a function to display the largest digit of a number.
31. WAP to make a function to display the sum of largest & lowest digit of a number.
32. WAP to make a function to display the given number is Armstrong or not.
33. WAP to make a function to display the given number is Automorphic or not.
34. WAP to make a function to display the given number is Perfect or not.
35. WAP to make a function to display the largest element in a vector.
36. WAP to make a function to display the sum of main diagonal of a matrix.
37. WAP to make a function to display the length of a string.
38. WAP to make a function to display the reverse of a string.
39. WAP to make a function to concatenation of two strings.
40. WAP to make a function to copy a string into another string.
41. WAP to make a function to convert the given string in lower case.
42. WAP to make a function to convert the given string in upper case.
43. WAP to make a function to compare a string into another string.

TATA-KANDRA MAIN ROAD NEAR SBI ATM ,Gamharia, Jamshedpur.


Call:9572419762,8603214022
12

You might also like