[go: up one dir, main page]

0% found this document useful (0 votes)
35 views3 pages

C++ Practice

The document outlines a series of programming exercises that cover basic to advanced concepts in programming, including input/output operations, arithmetic calculations, control structures, and array manipulations. Each exercise specifies a task to be accomplished, such as calculating sums, determining prime numbers, or manipulating arrays. The exercises are suitable for practice in languages like C++ and aim to enhance problem-solving skills in programming.

Uploaded by

zaingulrao8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

C++ Practice

The document outlines a series of programming exercises that cover basic to advanced concepts in programming, including input/output operations, arithmetic calculations, control structures, and array manipulations. Each exercise specifies a task to be accomplished, such as calculating sums, determining prime numbers, or manipulating arrays. The exercises are suitable for practice in languages like C++ and aim to enhance problem-solving skills in programming.

Uploaded by

zaingulrao8
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PRACTICE PROGRAMMES

1. Write a program to print HELLO WORLD on screen.


2. Write a program to display the following output using a single cout statement.
Subject Marks
Mathematics 90
Computer 77
Chemistry 69
3. Write a program which accept two numbers and print their sum.
4. Write a program which accept temperature in Fahrenheit and print it in centigrade.
5. Write a program which accept principle, rate and time from user and print the simple interest.
6. Write a program which accepts a character and display its ASCII value.
7. Write a program to swap the values of two variables.
8. Write a program to calculate area of circle.
9. Write a program to check whether the given number is even or odd (using ? : ternary operator )
10. Write a program to swap value of two variables without using third variable.
11. Write a program which input three numbers and display the largest number using ternary
operator.
12. Write a program which accepts amount as integer and display total number of Notes of
Rs. 500, 100, 50, 20, 10, 5 and 1.
For example, when user enter a number, 575, the results would be like this...
500: 1
100: 0
50: 1
20: 1
10: 0
5: 1
1: 0
13. Write a program which accepts a character and display its next character.

14. Write a program which accepts days as integer and display total number of years, months
and days in it.
for example : If user input as 856 days the output should be 2 years 4 months 6 days.

15. Any integer is input by the user. Write a program to find out whether it is an odd number
or even number.
16. Find the absolute value of a number entered by the user.
17. Write a program to calculate the total expenses. Quantity and price per item are input by
the user and discount of 10% is offered if the expense is more than 5000.
18. Write a program to determine whether the seller has made profit or incurred loss. Also
determine how much profit he made or loss he incurred. Cost price and selling price of an
item is input by the user.
19. If the ages of Ram, Sulabh and Ajay are input by the user, write a program to determine
the youngest of the three.
20. Write a program to check whether a triangle is valid or not, when the three angles of the
triangle are entered by the user. A triangle is valid if the sum of all the three angles is
equal to 180 degrees.
21. Any year is input by the user. Write a program to determine whether the year is a leap
year or not.
22. In a company an employee is paid as under:
If his basic salary is less than Rs. 1500, then HRA = 10% of basic salary
and DA = 90% of basic salary.
If his salary is either equal to or above Rs. 1500, then HRA = Rs. 500
and DA = 98% of basic salary.
If the employee's salary is input by the user write a program to find his gross salary.
23. Write a program to calculate the monthly telephone bills as per the following rule:
Minimum Rs. 200 for upto 100 calls.
Plus Rs. 0.60 per call for next 50 calls.
Plus Rs. 0.50 per call for next 50 calls.
Plus Rs. 0.40 per call for any call beyond 200 calls.
24. Write a program to find the roots of and quadratic equation of type ax2+bx+c where a is
not equal to zero.
25. The marks obtained by a student in 5 different subjects are input by the user. The student
gets a division as per the following rules:
Percentage above or equal to 60 - First division
Percentage between 50 and 59 - Second division
Percentage between 40 and 49 - Third division
Percentage less than 40 - Fail
Write a program to calculate the division obtained by the student.
26. Write a program to print number from 1 to 10.
27. Write a program to calculate the sum of first 10 natural number.
28. Write a program to find the factorial value of any number entered through the keyboard.
29. Two numbers are entered through the keyboard. Write a program to find the value of one number
raised to the power of another.
30. Write a program to reveres any given integer number.
31. Write a program to sum of digits of given integer number.
32. Write a program to check given number is prime or not.
33. Write a program to calculate HCF of Two given number.
34. Write a program to enter the numbers till the user wants and at the end it should display the count
of positive, negative and zeros entered.
35. Write a program to enter the numbers till the user wants and at the end it should display the
maximum and minimum number entered.
36. Write a program to print out all Armstrong numbers between 1 and 500. If sum of cubes of each
digit of the number is equal to the number itself, then the number is called an Armstrong number.
For example 153 = ( 1 * 1 * 1 ) + ( 5 * 5 * 5 ) + ( 3 * 3 * 3 )
37. Write a program to print Fibonacci series of n terms where n is input by user :
0 1 1 2 3 5 8 13 24 .....
38. Write a program to calculate the sum of following series where n is input by user.
1 + 1/2 + 1/3 + 1/4 + 1/5 +…………1/n
39. Compute the natural logarithm of 2, by adding up to n terms in the series
1 - 1/2 + 1/3 - 1/4 + 1/5 -... 1/n
where n is a positive integer and input by user.
40. Write programs to print following print patterns.

********** * *
********** ** **
********** *** ***
********** **** ****
***** *****

* 1 1 *********
*** 222 212 *******
***** 33333 32123 *****
******* 4444444 4321234 ***
*
********* 555555555 543212345

41. Write a program to compute sinx for given x. The user should supply x and a positive integer n.
We compute the sine of x using the series and the computation should use all terms in the series
up through the term involving xn
sin x = x - x3/3! + x5/5! - x7/7! + x9/9! ........

42. Write a program to compute the cosine of x. The user should supply x and a positive integer n.
We compute the cosine of x using the series and the computation should use all terms in the
series up through the term involving xn
cos x = 1 - x2/2! + x4/4! - x6/6! ...

1. Write a C++ program to find the sum and average of one dimensional integer array.
2. Write a C++ program to swap first and last element of an integer 1-d array.
3. Write a C++ program to reverse the element of an integer 1-D array.
4. Write a C++ program to find the largest and smallest element of an array.
5. Write a C++ program to find the most repeated element of an array.
6. Write a program to copy the contents of one array into another in the reverse order.
7. Write a program to read a 2D array matrix from the user and print the matrix
8. Write a program for addition of two Matrices of same size.
9. Write a program to find the sum of rows and columns of a Matrix.

You might also like