C Program for Check Armstrong Number

It is a sample C program to find accepted number is Armstrong number on not.


Program Source Code
//Write a program to check accepted number is armstrong number or not.
#include"stdio.h"
#include"conio.h"
void main()
{
  int i,no,r,sum=0;
  clrscr();
  printf("*******Armstrong Number******");
  printf("\n Enter a number");
  scanf("%d",&no);
  i=no;
  while(no!=0)
   {
    r=no%10;
    sum=sum+(r*r*r);
    no=no/10;
   }
   if(sum==i)
    printf("Number is a Armstrong number\n");
   else
    printf("Number is not a armstrong number\n");
   getch();
}


Output







Post a Comment

1 Comments
Amey Kumbhar said…
hello admin. please can you give me link where i can learn difference between structure and union in well manner. i had found this one http://www.technoexam.com/c-language-lecture-study-notes-tutorials-material/difference-between-array-and-structure.asp but it is between array and structure..