Friday 31 August 2012

ARMSTRONG NUMBER

#include<stdio.h>
#include<conio.h>
void main ()
{
int a,b,c,d,n,sum=0;
printf ("Enter the number");
scanf ("%d",&n);
a=n%10;
b=n/10;
c=b%10;
d=b/10;
sum = (a*a*a)+(c*c*c)+(d*d*d);
if (sum==n)
{
printf ("the number isarmstrong");
}
else
{
printf ("the number is not armstrong");
}
getch();
}http://www.google.co.in/

FIBONACCI SERIES IN C

#include<stdio.h>
#include<conio.h>
main()
{
int n,i,c,a=0,b=1;
printf("Enter Fibonacci series of nth term : ");
scanf("%d",&n);
printf("%d %d ",a,b);
for(i=0;i<=(n-3);i++)
{
c=a+b;
a=b;
b=c;
printf("%d ",c);
}
getch();
}

FACTORIAL OF A NUMBER

#include<stdio.h>
#include<conio.h>
void main()
{
int n,f;
f=1;
printf("Enter the number:\n");
scanf("%d",&n);

while(n>0)
{
printf("%d",n);
f=f*n;
n--;
}
printf("The factorial of the integer is:%d",f);
getch();
}