Header Ads Widget

Responsive Advertisement

Armstrong Number using Pow Function

 


#include <math.h>
#include <stdio.h>
int main() {
  int  number, q, rem, count = 0;
  int result = 0;
  printf("Enter A Number : ");
  scanf("%d",& number);
  q=number;
   
    // This is for Digits Calculation
  

    while(q!=0)
    {
    q=q/10;
    count++;
    }
    q=number;
   
    //This is for Armstrong Number Calculation

    while(q!=0)
    {
    rem=q%10;
    result=result+pow(rem,count);
    q=q/10;
    }
    if(result==number)
    printf("%d This is a Armstrong Number",number);
    else
    printf("%d This is Not a Armstrong Number",number);
 
return 0;
}


Post a Comment

0 Comments