Programming in C and Data Structures:
Module 2
if
switch
while
- Write a program to print n natural numbers 1, 2, 3 ………..…...... n
- Write a program to print n natural numbers n, n-1,.................3,2,1
- Write a program to check whether given number is Amstrong number or not
- Write a program to compute GCD and LCM
- Write a program to find the factorial of given number (4! -> 24)
- Write a program to print from a to z
- Write a program to find Fibonacci terms upto n
- Write a program to find sum of digits of given number
- Write a program to count number of digits in given number
do-while
- Write a program to calculate cos(x) = 1 - (x2/2!) + (x4/4!) - (x6/6!) +……………………..
- Write a program to calculate sin(x) = x - (x3/3!) + (x5/5!) - (x7/7!) +……………………..
- Write a program to count number of digits in given number
for
- Write a program to print n natural numbers 1, 2, 3 ………..…...... n
- Write a program to print n natural numbers n, n-1,.................3,2,1
- Write a program to print odd numbers
- Program to print sum of n natural numbers 1+2+3+……………….+n
- Write a program to find the sum of series 1 + 2 + 4 + 7 + 11 + 16 + .............
- Write a program to find sum of series 1 + x + x2 + x3 + x4 + ………. + xn
- Program to print sum of even and odd numbers
- Write a program to find the factorial of given number (4! -> 24)
- Write a program to print n Fibonacci terms
- Write a program to find sum of series 1+ (1/2) + (1/3) + …………. + (1/n)
- Write a program to find sum of series (1/1!)+(2/2!) + (3/3!) + ………………… + (n/n!)
- Program to print pattern:
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*
1
2 3
4
5 6
7
8 9 10
11
12 13 14 15
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
break
- Program to demo break statement
continue
- Program to demo continue statement
- Program to find sum of 5 positive numbers
goto
- Program to demo goto statement
exit
- Program to demo exit statement
- Write a program to check given number is prime or not