0

Hi,every one I am going to find whether the given number is a armstrong number or not and I have done my level best and I need your help in one thing,If any mistakes,please reply and I need your other views to develop my C skills.hope help from you all

thank you
vinaychalluru

Attachments
/*Program to find whether the given number is an armstrong number or not*/

                                                              armstrong number an example:135=1*1*1+3*3*3+5*5*5=135;
                                                             
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main(0
{
int n,m,i,rem,sum=0;
printf("enter the number to be checked:");
scanf("%d",&n);
m=n;
while(n>0)
{
rem=n%10;
sum=sum+pow(rem,3);
n=n/10;
}
if(m==sum)
{
printf("the given number is an armstrong number");
}
else
printf("The given number is not an armstrong number");
getch();
}
6
Contributors
6
Replies
7
Views
9 Years
Discussion Span
Last Post by Narue
0

hope this helps u gettin final code...

eg:..to find 3 digit armstrong number:

void main()
{
int a,b,c,i;

printf("enter a 3 digit number\n");
scanf("%d",&i);

a=(i-(i%100))/100;
b=((i%100)-(i%10))/10;
c=i%10;
num=(a*a*a)+(b*b*b)+(c*c*c);
if(num==i)
printf("\nthis is armstrong");
getch();
}
0

Hi,
I have a soln for solving armstrong numbers

#include<stdio.h>
#include<conio.h>
void main()
{
 int i,j,n,r,c,k;
 clrscr();
 printf("Armstrong numbers\n");
 for(i=1;i<=500;i++)
{
 c=0;
 n=i;
 k=n;
 while(n!=0)
 {
    r=n%10;
    c=c+(r*r*r);
    n=n/10;
}
if(c==k)
printf("%d\n",k);
}
getch();
}
0

>hope this helps u gettin final code...
>I have a soln for solving armstrong numbers
I take solace in the fact that people who give away homework solutions usually come from the shallow end of the programmer pool. :icon_rolleyes:

0

Hi nitishssingh. I read the PM you sent me, and no, I won't help you cheat your way through school.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.