C++ LANGUAGE PROGRAMMING

Q1. Write a program to print a string on the screen.

Q2. Write a program to show the use of ‘char’ data type.

Q3. Write a program to print the sum of two numbers.

Q4. Write a program to read two values from user and print there sum.

Q5. Write a program to input two values and print their addition, subtraction, multiplication and division.

Q6. Write a program to show the use of chain assignment.

Q7. Write a program to show the use logical operator.

Q8. Write a program to show the use of addition C++ shorthand operator.

Q9. Write a program to show the use of subtraction C++ shorthand operator.

Q10. Write a program to show the use of multiply C++ shorthand operator.

Q11. Write a program to show the use of division C++ shorthand operator.

Q12. Write a program to show the use of modulus C++ shorthand operator.

Q13. Write a program to make use of ternary operator/conditional operator.

Q14. Write a program to make use of ternary operator/conditional operator.

Q15. Write a program to take input in three subjects Physics, Chemistry and Math’s and calculate the total and percentage.

Q16. Write a program to input users age and display a message you can vote or cannot vote.

Q17. Write a program to accept a character and determine whether it’s upper case or lower case.

Q18. Write a program to accept a character and determine whether its number, alphabet or symbol.

Q19. Write a program to accept a number and determine whether it is even or odd.

Q20. Write a program to accept a number and if it is less than 10 then print its square value.

Q21. Write a program to accept a number and if it is less than 50 and greater than 20 than print its square value.

Q22. Write a program to accept percentage and print division accordingly.

Getting started with C++

Q23. Write a program to print a string on the screen.

Q24. Write a program to print sum of two values.

Q25. Write a program to calculate the square of a number.

Q26. Write a C++ program that inputs a student’s marks in three subjects (out of 100) and prints the percentage marks.

Q27. Write a program to display the following output using a single cout statement.

Program = 20

Documentation = 23

Logic = 21

Flow chart = 18

Q28. Write a program to read values of w, x, y and z and display the value of P, where

P= w+x / y-z

Q29. Write a C++ program that reads temperature in Celsius and displays it in Fahrenheit.

Q30. Write a program that displays on screen

  1. the character ‘z’
  2. the name ‘Mohan’
  3. the number 1977

Using

Q31. Assuming that there are 7.481 gallons in a cubic foot, write a program that asks the user to enter the number of gallons, and then displays the equivalent in cubic feet.

Q32.Write a program to generate the following table:

        1992                       17421

        1993                       29210

        1994                       100523

        1995                       106802

        1996                       127000

Use a single cout statement for output.

(Hint : Make use of \n anf \t)

Q33. Write a program that generates the following output:

        5

        10

        9

Assign value 5 to a variable using =. Multiply it with 2 to generate 10 and subtract 1 to generate 9.

 Q34. Write a C++ program that accepts marks in 5 subjects and outputs average marks.

DATA HANDLING

Q35. Write a C++ program to display ASCII code of a character and vice versa.

Q36. Write a C++ program (using a function) to accept a number and print its cube.

Q37. Write a C++ program to compute the area of a square. Make assumption on your own.

Q38. Write a C++ program to convert a given number of days into years, weeks and days.

Q39. Write a C++ program that accepts a character between a to j and prints next 4 characters.

Q40. Write a short program that asks for your height in centimeters and then converts your heights to feet and inches. (1 foot = 12 inches, 1 inch = 2.54 cm).

Q41. An electricity board charges according to following rates:
For the first 100 units – 40 P per unit  (P-Paise)

For the next 200 units – 50 P per unit

Beyond 300 units – 60 P per unit.

All users are charged meter charge also which is R50/-.

Write a program to read the names of users and number of units consumed, and print out the charges with names.

Q42. Write a program to read a number n and print n2, n3, n4 and n5.

Q43. Write a program to find area of a triangle.

Q44. Write a program to find whether a given number is even or odd.

Q45. Write a program to accept three digits (that is, 0-9) and print all possible combinations from these digits. (For example, if the three digits are 1, 2 and 3 then all possible combinations are 123, 132, 231, 213, 312 and 321).

Q46. Write a program to convert given inches into its equivalent yards, feet and inches.

(1 yard = 36 inches, 1 foot = 12 inches)

Q47. Write a program to read two numbers and print their quotient and remainder.

Q48. Write a program to compute simple interest and compound interest.

Q49. Write a program to

(Hint: Store escape sequence for backspace in an integer variable).

Operators and Expressions in C++

Q50. Write a C++ program to perform chain multiple assignments (as many as possible).

Q51. Write a C++ program that inputs experience and age of a person. The salary of the person is 6000 if the person is experienced and his age is more than 35, otherwise if the person is experienced and his age is more 28 but less than 35 than the salary should be 4800 otherwise for experienced person the salary should be 3000 and for inexperienced person the salary be 2000.

Q52. A computer programming contest requires teams of 5 members each. Write a program that asks for the number of players, and then gives the number of teams and number of players left over.

Q53. The value of e is known to be 2.71828….. Using this value, write a program to determine the value of the expression: 2-ye2y+4y.  Obtain value of y from user.

Q54. Write a program which will raise any number X to a positive power n. Obtain values of x and n from user.

Q55. Write a C++ program to input principal amount and time. If time is more than 10 years, calculate the simple interest with 8%. Otherwise calculate it with rate 12% per annum.

Q56. Write a C++ program to input a number. If the number is even, print its square otherwise print its cube.

Q57. Write a C++ program to input a number. If the number n is odd and positive, print its square root otherwise print n5.

Q58. Write a C++ program to input choice (1 or 2). If choice is 1, print the area of a circle otherwise print the perimeter of circle. Accept the radius of circle from user.

Q59. Write a program to input three integers and print the largest of three.

Q60. Write a C++ program to input a student type (‘A’ or ‘B’). if the student type is ‘A’ initialize the college account with Rs. 200/- otherwise initialize the hostel account with Rs. 200/-.

Q61. Write a program that reads in a character <char> from the keyboard and then displays one of the following messages:

Hint. You will need to refer to a table of ASCII characters. Lowercase letters have ASCII value range 97-122. Uppercase letters have ASCII value range 65-90.

 

%d bloggers like this: