1. C program to display 5,10,15,.....
50
#include <stdio.h>
int main()
{
int i;
for(i=5;i<=50;i=i+5)
{
printf("%d\n",i); }
return 0; }
2. C program to display 5,10,15,..... up to 50th terms
#include <stdio.h>
int main()
{ int i,a=5;
for(i=0;i<=50;i++)
{ printf("%d\n",a);
a=a+5; }
return 0; }
3. C program to display 1,2,4,8,16,..... up to
10th terms
#include <stdio.h>
int main() {
int i,a=1;
for(i=0;i<10;i++) {
printf("%d\n",a);
a=a*2; }
return 0; }
4. C program to display 1,2,4,7,11,..... up to
10th terms
#include <stdio.h>
int main()
{ int i,a=1;
for(i=0;i<10;i++)
{
a=a+i;
printf("%d\n",a); }
return 0; }
5. C program to display 2,8,18,32,..... up to 10th terms
#include <stdio.h>
int main() { int i,a;
for(i=1;i<=10;i++) {
a=i*i*2;
printf("%d\n",a); }
return 0; }
6. C program to display 999,728,511,..... up to
10th terms
#include <stdio.h>
int main() { int i,ans;
for(i=10;i>=1;i--) {
ans=i*i*i-1; printf("%d\n",ans); }
return 0; }
7. C program to display 100,98,94,88,80,..... up to
10th terms
#include <stdio.h>
int main() { int i,ans=100,b=2;
for(i=0;i<10;i++) {
printf("%d\n",ans);
ans=ans-b;
b=b+2; }
return 0; }
8. C program to display 7,22,11,34,17,..... up to
10th terms(Hailstone Series)
Start with any integer value greater than 0, say x. If x is even, then the next value
in the series is x/2; if x is odd, then the next value in the series is 3x + 1. This
type of series is called Hailstone series
#include <stdio.h>
int main() { int a=7,r,i;
for(i=0;i<10;i++) {
printf("%d\n",a); r=a%2;
if(r==0) a=a/2;
else a=a*3+1; }
return 0; }
9. C program to display 0,1,1,2,3,5,8,13,..... up to
50th terms (Fibonacci Series)
An integer in the infinite sequence 0,1, 1, 2, 3, 5, 8, 13, ..... of which the first two
terms are 0 and 1 and each succeeding term is the sum of the two immediately
preceding is called Fibonacci Series.
#include <stdio.h>
int main() {
int a=0,b=1,c,i;
for(i=0;i<10;i++)
{
printf("%d\n",a);
c=a+b; a=b; b=c;
} return 0; }
10. C program to display the series with their sum
1,2,3,4,..... up to 10th terms
#include <stdio.h>
int main()
{ int i,sum=0;
for(i=1;i<=10;i++)
{
printf("%d\t",i);
sum=sum+i; }
printf("Sum of series from 1-10 is %d",sum);
return 0; }
11. C program to display all even numbers from 2 to20
and find their sum.
#include <stdio.h>
int main() {
int i,sum; for(i=2;i<=20;i=i+2) {
printf("%d\n",i);
sum=sum+i;
} printf("Sum of even numbers from 2 to 20 is %d " , sum);
return 0; }
12. C program to find the factorial of the given number.
The product of a given positive integer multiplied by all
lesser positive integers: The quantity five factorial (5!)
= 5x4 x 3 x 2 x 1 = 120.
#include <stdio.h>
int main()
{ int num,i,f=1;
printf("Enter any number : ");
scanf("%d",&num);
for(i=num;i>=1;i--) {
f=f*i;
}
printf("\n Factorial of %d is %d",num,f);
return 0; }
13. C program to display factors of a supplied number.
#include <stdio.h>
int main()
{
int num,i;
printf(" Enter any number : ");
scanf("%d",&num);
printf("Factors of %d are : ",num);
for(i=1;i<=num;i++) {
if(num%i==0)
printf(" %d\n ",i); } return 0; }
14. C program to check whether the supplied number
is prime or composite.
#include <stdio.h>
int main()
{ int num,i,count=0;
printf("Enter a number");
scanf("%d",&num);
for( i=1;i<=num;i++)
{
if(num%i==0) count++; }
if(count==2)
printf("%d is prime number",num);
else
printf("%d is composite number",num);
return 0; }
15. C program to display all prime numbers from 1 to
100.
#include <stdio.h>
int main() {
int num,i,count;
for(num=1;num<=100;num++)
{
count=0;
for(i=1;i<=num;i++)
{
if(num%i==0)
count++; }
if(count==2)
printf(" %d\n ",num); }
return 0; }
16. C program that asks a multi-digit number and
calculates the sum of its individual digits.
#include <stdio.h>
int main() {
int num,r,sum=0;
printf(" Enter any number ");
scanf("%d",&num);
while(num!=0)
{
r=num%10;
sum=sum+r; num=num/10;
}
printf("Sum of individual digits is %d",sum);
return 0; }
17. C program to display the reverse of a supplied
number.
#include <stdio.h>
int main()
{
int num,a,r,sum=0;
printf("Enter any number ");
scanf("%d",&num);
a=num; while(num!=0)
{
r=num%10;
sum=sum*10+r;
num=num/10;
}
printf("Reverse of %d is %d",a,sum); return 0; }
18. C program to test whether the supplied number is
Palindrome number or not.
#include <stdio.h>
int main()
{
int num,a,r,sum=0;
printf("Enter any number ");
scanf("%d",&num);
a=num;
while(num!=0)
{
r=num%10;
sum=sum*10+r;
num=num/10;
}
if(a==sum)
printf(" %d is Palindrome Number",a);
else
printf(" %d is not Palindrome Number",a); return 0; }
19. C program to check whether the given number is
Armstrong or not.
An Armstrong number is a number which equal to the
sum of the cubes of its individual digits. For example:
153 is an Armstrong number as-
153=(1)3+(5)3+(3)3=1+125+27=153
#include <stdio.h>
int main()
{
int num,a,r,sum=0;
printf("Enter any number");
scanf("%d",&num);
a=num;
while(num!=0)
{
r=num%10;
sum=sum+r*r*r;
num=num/10;
} if(a==sum)
printf("%d is Armstrong number",a);
else
printf("%d is not Armstrong number",a);
return 0; }
20. C program to display:
22
333
4444
55555
#include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++) {
printf(" %d ",i);
}
printf("\n"); }
return 0; }