Problem 65. C Program to check whether a given number is Armstrong or not (Process IV).
#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r,k;
clrscr( );
printf(“enter a number”);
scanf(“%d”,&n);
k=n;
s=0;
while(n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(k==s)
printf(“given number is Armstrong %d”,k);
else
printf(“given number is not Armstrong %d”,k);
}
getch();
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignment#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r,k;
clrscr( );
printf(“enter a number”);
scanf(“%d”,&n);
k=n;
s=0;
while(n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(k==s)
printf(“given number is Armstrong %d”,k);
else
printf(“given number is not Armstrong %d”,k);
}
getch();
}
C compiler: gcc 4.1.2