About us

C Program to find given number Armstrong or not

C Program to find given number Armstrong or not

C-Program-find-number-Armstrong-or-not

Armstrong Number

A Three digits integer number will be called Armstrong number, if the sum of cubes of its every digit is equal to that number. For Ex:-371
33+73+13=27+343+1=371


Program

#include<stdio.h>
#include<conio.h>
void main()
{
 int n,z,r,p=0;
 clrscr();
 printf("Enter any Three digits Number\n");
 scanf("%d",&n);
 z=n;
 while(n!=0)
 {
  r=n%10;
  p=p+(r*r*r);
  n=n/10;
 }
 if(p==z)
  printf("given number is an Armstrong number\n");
 else
  printf("given number is not an Armstrong number\n");
 getch();
}

Output

Enter any Three digits Number
153
given number is an Armstrong number






You can also visit:-