Chapter 5: Programming ExercisesΒΆ

1. Write a program to print the first 100 prime numbers. A prime number any number that can be divided by itself and by 1. Use cin and cout. 2. Write a program to produce the first 100 Fibonacci numbers. A Fibonacci number is one that is the product of the prior two generated numbers. The sequence is seeded with the values of 0 and 1, so that the sequence starts off as 0 1 1 2 3 ... Fibonacci numbers are used in computing hash table locations for file management systems. Use cin and cout 3. The factorial of an integer n, written n!, is the product of the consecutive integers 1 through n. For example, 5 factorial is calculated as 5! = 5 * 4 * 3 * 2 * 1 = 120 Write a program to generate and print a table of the first 10 factorials. 4. Produce a table showing values of x, the square of x and the cube of x for values of x from 1 to 50.

Previous topic

Chapter 5 Making Decisions and Looping

Next topic

Chapter 5: Programming Projects

This Page