Our Blog Contain Detail about Some Technical Aspect like Programming, Blogger, Tools and Tip, Suggestion, Motivational, Health, Program in C and Java, Html

Write a program to print out all the Armstrong number between 100 and 500.

Write a program to print out all the Armstrong number between 100 and 500.



Program in C Language

#include<stdio.h>

#include<conio.h>
int checkams(int num);
void main()
{
     int i;
     for(i=100;i<=500;i++)
     {
          if(checkams(i))
          {
               printf("%d\n",i);
          }
     }
     getch();
}


int checkams(int num)
{

   int digit,sum=0,temp;
  // printf("enter an number\n");
  // scanf("%d",&num);
   temp=num;
   while(num!=0)
   {
        digit=num%10;
        num=num/10;
        sum=sum+digit*digit*digit;
   }
   if(sum==temp)
   {
        return 1;
   }
   else
   {
        return 0;
   }

}


Share:

No comments:

Post a Comment

Translate

Followers

Email Subscription

Enter your email address:

Delivered by FeedBurner

Recent Posts

Theme Support

Need our help to upload or customize this blogger template? Contact me with details about the theme customization you need.