C, C++, etc Programing examples. Post as many you can. Test the programs and discuss about the output of the programes.
Forum rules
Please Discuss & post only about the programes and its Output
by rohit.wadhwa » Sat Mar 21, 2009 6:21 pm
- Code: Select all
/* PROGRAM TO FIND IF THE GIVEN NUMBER IS AN ARMSTRONG NUMBER OR NOT */
/*author-Rohit Wadhwa*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int num;
int temp,a;
int count=0,sum=0;
clrscr();
printf("Enter a number=");
scanf("%d",&num);
for(temp=num;temp>0;)
{
a=temp%10;
temp=temp/10;
count++;
}
for(temp=num;temp>0;)
{
a=temp%10;
sum+=pow(a,count);
temp=temp/10;
}
if(sum==num)
{
printf("%d IS AN ARMSTRONG NUMBER...",num);
}
else
{
printf("%d IT IS NOT AN ARMSTRONG NUMBER...",num);
}
getch();
}
-

rohit.wadhwa
- Moderator
-
- Posts: 55
- Joined: Mon Mar 16, 2009 4:00 pm
- Location: Hisar(Haryana)
- membership: Senior Technician of The Institution of Engineers (India)- ST
-
by praveen » Sat Mar 21, 2009 9:59 pm
Good... Thanks for the post..
-

praveen
- Site Admin
-
- Posts: 989
- Joined: Thu Oct 23, 2008 1:42 pm
- Location: Mumbai
- membership: Senior Technician of The Institution of Engineers (India)- ST
-
Return to Computer Notes : Some Sample Programs
Who is online
Users browsing this forum: No registered users and 0 guests