C++ programming exercises for beginners

Lists of programming exercise for absoulute beginners

1. Write a program that prompts the user to input a decimal number and outputs the number rounded to the nearest integer.
2. Write a program that prompts the user to enter five test scores and then prints the average test score. (Assume that the test scores are decimal numbers.)
3. (Hard drive storage capacity) If you buy a 40 GB hard drive, then chances are that the actual storage on the hard drive is not 40 GB. This is due to the fact that, typically, a manufacturer uses 1,000 bytes as the value of 1K bytes, 1,000 K bytes as the value of 1 MB, 1,000 MB as the value of 1 GB. Therefore, a 40 GB hard drive contains 40,000,000,000 bytes. However, in computer memory, as you know before 1 KB is equal to 1,024 bytes, and so on. So the actual storage on a 40 GB hard drive is approximately 37.25 GB. (You might like to read the fine print next time you buy a hard drive.) Write a program that prompts the user to enter the size of the hard drive specified by the manufacturer, on the hard drive box, and outputs the actual storage capacity of the hard drive
4. Write a program that prompts the user to input three numbers. The program should then output the numbers in ascending order.
5.Write a c++ program that prompt the user to input the shape type (rectangle, circle, or cylinder) and the appropriate dimension of the shape. The program then outputs the following information about the shape: For a rectangle, it outputs the area and perimeter; for a circle, it outputs the area and circumference; and for a cylinder, it outputs the volume and surface area.
6.In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.
7. Let l be a line in the x-y plane. If l is a vertical line, its equation is x = a for some real number a. Suppose l is not a vertical line and its slope is m. Then the equation of l is y mx+b, where b is the y-intercept. If l passes through the point (x0, y0,), the equation of l can be written as y-y0=m(x-x0). If (x1, y1) and (x2, y2) are two points in the x-y plane and x1≠x2 , the slope of line passing through these points is m=(y2-y1)/(x2-x1). Write a program that prompts the user two points in the x-y plane. The program outputs the equation of the line and uses if statements to determine and output whether the line is vertical, horizontal. If l is a non-vertical line, output its equation in the form y=mx+b

8. writre a program that test divisibility of a number by 3 and 9.
9. write a c++ program that display the below pattern
*****
*****
*** *
*****
*****
10. write a cpp program that display the below pattern.

2
2 4
2 4 6
2 4 6 8
2 4 6 8 10
11/. write a c++ program that read 20 intiger and dispaly the number of odds and evens including zeros.
12. write a cpp program that compare the larger of three numbers by using function.
13.write a c++ program by using function that accept the first and the second fibonnaci numbers and also accept the position of the desired fibonnaci series and output the desired fibonnaci number.

14.write a c++ program by using function that output the course grade of a sutudents by accepting their result out of 100.

DO YOUR BEST!

Comments

Popular posts from this blog

Solutions for even numbered questions in C++ exercises for beginners

C++ sample Exams with their answers