C Program for Armstrong numbers

by Nideesh C on April 18, 2011 · 1 comment

in C Programming




#include<stdio.h>
#include<math.h>
void main()
{
int lim_up,n,dig,sum,num;
clrscr();
printf(“nnt ENTER THE UPPER LIMIT…: “);
scanf(“%d”,&lim_up);
printf(“nnt ARMSTRONG NUMBERS ARE…: “);
for(n=1;n<lim_up;n++)
{
sum = 0;
num = n;
while(num>0)
{
dig = num%10;
sum = sum+pow(dig,3);
num = num/10;
}
if(sum == n)
printf(“nnttt%d”,n);
}
getch();
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C Program To find the sum of digits
  2. C Program To reverse a given number
  3. C Program to check whether a given number is palindrome or not
  4. C program to find the sum of first 50 natural numbers using for loop
  5. C Program – Find the sum of secondary diagonal of a Matrix

{ 1 comment… read it below or add one }

1 Disusa April 21, 2011 at 5:10 pm

C Program for Armstrong numbers

Reply

Leave a Comment

Previous post:

Next post: