C++ Programs Essay
1. Write a program program in C++ to find the square of the numbers from 1 to 10 using : (a) for loop (b) while loop(c) do-while loop
The output of the program should be in the following format: NumberSquare
2. Write a program in C++ that calculates the value of π from the infinite series [pic]
Print a table that shows the value of π approximately by 1 term of the series, by two terms, by three terms, etc. How many terms of this series do you have to use before you first get 3.14? 3.141? 3.1415?3.14159?
3. Write a program in C++ to find the sum of the first 20 terms of the following series sum = 1 – (1/1!) + (2/2!) – (3/3!) + (4/4!) …………. (n/n!)
4. Write a program in C++ that prints the factorial of the given number using : (a) for loop (b) while loop(c) do-while loop
Make sure that the program correctly handles the exceptions such as the value of factorial zero and the value of factorial of a negative number.
5. Write a C++ program that checks whether a number entered by the user is a perfect number or not. (Note: A perfect number is the one whose all the divisors sum up the number itself. For example, number 28 is a perfect number as 1+2+4+7+14=28).
6. Write a program in C++ to read a set of 10 positive integers and display them all. If the number entered is zero, the program continues reading, but when the user input is a negative number, the program stops reading any further input and displays a message: “a negative number entered”.
7. Write a program that reads three non-zero double values and determines and prints whether they could represent sides of a triangle. 8. Write a program to evaluate the quadratic polynomial a x2 + bx + c for a given set of values of a,b, c and x. Write another program which would evaluate the roots of this quadratic polynomial.Your program must test whether roots are real and imaginary and display them accordingly.
. 9 .Write a program that reads three non-zero integer values and determines and prints whether they could represent sides of a right-angled triangle.
10.. Write a program in C++ to read a number n, and digit d, and check whether d is present in the number n. If it is so, find out the position of d in the number n. for example in the case of n =75689 and d = 5; the digit 5 is present in the number at the position 4 from right (lsb).
11. Write a program to print all the combinations of numbers 1,2 and 3. (i.e., 123,132,213,….).
.12.Implement the Euclidean Algorithm for finding the greatest common divisor of two given positive integers. This algorithm transforms a pair of positive integers (m,n) into a pair (d,0) by repeatedly diving the larger integer by the smaller integer and replacing the larger with the remainder. When the remainder is zero, the other integer in the pair will be the greatest common divisor of the original pair.
13. Write a program that allows the user to enter two positive decimal numbers (the numbers entered could have negative signs). The program should then convert the numbers to binary form and carry out addition of the two binary numbers using binary arithmetic for unsigned integers. The program should display the output as The binary equivalent of 8 and 7 are 1000 and 111 and they add up to 1111.
14. Write a program to evaluate sine value of an angle in degrees entered by the user using the following series. Prompt the user to enter the number of terms to evaluate. Display the %error involved based on the difference between the value estimated and found using the standard C++ library function. The program should terminate only when a negative angle is entered. sin(x) = 1-x3/3! + x5/5! -….
15. Write a program which adds the no. of elements of an array using a for loop.
University/College: University of Arkansas System
Type of paper: Thesis/Dissertation Chapter
Date: 19 October 2016
We will write a custom essay sample on C++ Programs
for only $16.38 $12.9/page