google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program to find whether the given number is an Armstrong number - 2nd puc computer science

Write a program to find whether the given number is an Armstrong number

Write a program to find whether the given number is an Armstrong number

Write a c program to find whether the given number is an Armstrong number,
Write a program to find whether the given number is an Armstrong number in c

#include<stdio.h>

#include<conio.h>

void main()

{

int n,sum=0,num,digit;

clrscr();

printf("Enter the number: ");

scanf("%d",&n);

num=n;

do

{

         digit=n%10;

         sum=sum+digit*digit*digit;

         n=n/10;

}while(n!=0);

if(sum==num)

printf("It is an Armstrong number");

else

printf("It is not an Armstrong number");

getch();

}

Output:


run 1:

Enter the number: 153

It is an Armstrong number

 

run 2:

Enter the number: 220

It is not an Armstrong number

Write a program to find whether the given number is an Armstrong number Write a program to find whether the given number is an Armstrong number Reviewed by Vision Academy on December 08, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.