Tuesday, September 16, 2014

Day 4 - 2: Using for loop do some exercise

1. Declare a variable which has the age of the person. Print the user’s name as many times as his age

2. The program displays even numbers from 1 to 30.

3. The program displays numbers from 10 to 0 in the reverse order

4. The program will accept integers and display them until zero (0) is entered

5.  Find the factorial of a number.
 Hint:
  1. Get the number.
  2. To begin, set the factorial of the number to be one.
  3. While the number is greater than one
  4. Set the factorial to be the factorial multiplied by the number.
  5. Decrement the number.
  6. Print out the factorial

6.  Write a program to print the series 100, 95 , 90, 85,………., 5.

7.   Accept two numbers num1 and num2. Find the sum of all odd numbers between the two
 numbers entered .

8.  Write a program to generate the Fibonacci series. (1,1,2,3,5,8,13,………)

No comments:

Post a Comment