Friday, 28 January 2022

Write a program in C to check the number is Armstrong Number or not :

 **What  is  Armstrong  Number  :-

                                                    Before going to the Armstrong program , Let's understands what is  Armstrong number and the answer is Armstrong Number is a number that is equal to the sum of cubes of it's digits . Now begin the examples of an Armstrong numbers are 0, 153, 370,371,407 etc Let's try to understand why 371 is an Armstrong Number ....

371  =  (3*3*3)+(7*7*7)+(1*1*1)

Where :

(3*3*3)  =  27

(7*7*7) = 343

(1*1*1) = 1

So :

27+343+1 = 371

Let's see the program :

Main Program :-

#include<stdio.h>  

 int main()    

{    

int n,r,sum=0,temp;    

printf("enter the number=");    

scanf("%d",&n);    

temp=n;    

while(n>0)    

     {    

        r=n%10;    

        sum=sum+(r*r*r);    

        n=n/10;    

      }    

if(temp==sum)    

        printf("armstrong  number ");    

else    

        printf("not armstrong number");    

return 0;

}

Input  :-                                                                                                                                                   


Output :-                                                                                                                                                     

Number is Armstrong                                                                                                                                   

Number is Not Armstrong Number                                                                                                           


                                                                                                                                                                                                                         
  IF YOU HAVE ANY QUARRIES SO YOU CAN DIRECTLY CONTACT WITH US,GO INTO THE CONTACT   INFORMATION PAGE AND THEN TYPE YOUR QUARRIES .

 THANKS FOR VISITING . IF YOU LOVE PROGRAMMING THEN YOU CAN FOLLOW OUR WEBSITE .....

1 comment:

Infosys Process Executive Recruitment 2022 | Apply Now

  Infosys Process Executive Recruitment 2022 | Apply Now  Infosys Process Executive Recruitment 2022 |Infosys Recruitment 2022 | Work From H...