Have a Read!

Hi Everyone.
The idea for this page is to provide new c users simple c tutorials to learn how to develop the logic and more importantly correct way to write syntax.
ENJOY !!!

Saturday, January 29, 2011

C PROGRAM FOR ARMSTRONG NUMBER

#include<stdio.h>
int main () {
int num,n,sum,r;
printf("ENTER THE NUMBER\n");
scanf("%d",&num);
n=num;
sum=0;
while(n!=0)
  {
    r=n%10;
    sum=sum+(r*r*r);
    n=n/10;
  }
if(sum==num)
   {printf("\n%d is armstrong number\n",num);}
else
   {printf("\n%d is not armstrong number\n",num);}
return 0;
}  

No comments:

Post a Comment

Related Posts with Thumbnails