Exercise programs on while loop
1. Write a python program to add first N natural numbers
sum = 1+2+3+...+n
Hint: read value of n from user
Set initial value of sum to 0
Create loop which runs for n time
For each time while loop condition is true, add current value to sum
2. Write a python program to find product first N natural numbers
product = 1*2*3*...*n
Hint: read value of n from user
Set initial value of product to 1
Create loop which runs for n time
For each time while loop condition is true, multiply current value with product
and store result into product
3. Write a python program to reversing a number using while loop and check that number is
a palindrome or not.
4. Write a python program to find the factorial of a given number using while loop.
5. Write a python program to print the square of all numbers from 0 to 10
6. Write a python program to find the sum of all even numbers from 0 to 10
7. Write a python program to read three numbers (a,b,c) and check how many numbers
between ‘a’ and ‘b’ are divisible by ‘c’
8. Write a python program to get the following output
1-----99
2-----98
3-----97
..
..
..
98-----2
99-----1