C program to check Armstrong number


                           Before the perform this program first we need to clear that what is Armstrong no.. Armstrong no. is a number who's sum of every digits cube is equal to that number is Armstrong no. For example 153 is Armstrong no. 1^3+5^3+3^3 (1+125+27) =153.

C program to check number is armstrong or not


#include<stdio.h>

void main()
{
       int no,temp,rem,no1;
       temp=0;

       clrscr();

       printf("Enter no.::");
       scanf("%d",&no);
       no1=no;

       while(no>0)
       {
              rem=no%10;
              temp+=rem*rem*rem;
              no=no/10;
       }

       if(temp==no1)
       {
              printf("No is armstrong");
       }
       else
       {
              printf("No. is not armstrong");
       }

       getch();
}


c program for armstrong number


0 comments:

Post a Comment