Assignment 1
1. Write a program to calculate the factorial of a number using a while loop.
The factorial of a positive number n is given by:
factorial of n (n!) = 1 * 2 * 3 * 4 * ... * n
2. Write a program to print fibonacci series (10 values).
A series where the next term is the sum of previous two terms. The first
two terms of the Fibonacci sequence is 0 followed by 1.
The Fibonacci sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, ...
3. Write a program to sort the elements of an array in ascending order.
4. Write a program to check whether the current year is leap year or not. Users will
enter a year value.
5. Write a program to print the first 10 prime numbers.
6. Write a program to calculate the area of a triangle. Users will enter the values for
base and height of the triangle.
7. Write a program to print the sum of the first 20 natural numbers.
8. Write a program to reverse the elements of an array where the array size as well as the
array values are entered by the user.
9. Write a program to print only even numbers till 50.
10. Write a program to print this output using a two-dimensional array.
Triangle Array
00
000
0000
00000
000000
0000000
00000000
000000000
0000000000