[text] sneh

Viewer

  1. #include<stdio.h>
  2. #include<math.h>
  3. int main(){
  4.         int arm,cnt,a,b,x;
  5.         printf("Enter a number :");
  6.         scanf("%d",&a);
  7.        
  8.         b=a;
  9.         cnt=0;
  10.         while(a!=0){
  11.                 cnt++;
  12.                 a=a%10;
  13.         }
  14.         a=b;
  15.         while(a!=0){
  16.                 x=a%10;
  17.                 arm=arm+pow(x,cnt);
  18.                 a=a/10;
  19.         }
  20.                 if(arm==b){
  21.                 printf("the given no is armstrong number");
  22.         }
  23.                 else{
  24.                 printf("the given no is not armstrong number");
  25. }
  26. return 0;
  27. }

Editor

You can edit this paste and save as new:


File Description
  • sneh
  • Paste Code
  • 16 Apr-2024
  • 391 Bytes
You can Share it: