Tuesday, May 10, 2022

Check Armstrong Number or Not in C programming


Check Armstrong Number of n Digits     


Hello friends ...welcome to learn today 

In this blog we will discuss about what is armstong number ?  And  How its works in C Programming ?

What is armstrong number ?

 The given digits is same as the power of digits is sum , that is called armstrong number.

for example ,

 the given digits is 407 ,is same as the (4*4*4)+(0*0*0)+(7*7*7)=(64)+(0)+(343)=407 this is called a armstrong number.

Suppose, the given digits is 234, is does not same as the 

(2*2*2)+(3*3*3)+(4*4*4)=(8)+(27)+(64)=99 


 Check Armstong Number or Not in C Programming

#include<stdio.h>

#include<conio.h>

void main()

{

    int num,rem,sum=0,temp;

    clrscr();

    printf("\n\t Check Armstrong Number or Not ");

    printf("\n\t ***** ********* ******* ** ***");

    printf("\n Input");

    printf("\n ^^^^");

    printf("\n Enter the Number : ");

    scanf("%d",&num);

    printf("\n Output");

    printf("\n ^^^^^^");

    temp=num;

    while(num>0)

    {

        rem=n%10;

        sum-sum+(rem*rem*rem);

        n=n/10;

}

if(temp==sum)

{

    printf("\n %d is an armstrong number ",temp);

else

    printf("\n %d is not an armstong number ",temp);

}

getch();

}

Output





No comments:

Post a Comment

ERROR CONTROL IN DATA COMMUNICATION AND NETWORKS

ERROR CONTROL IN DATA COMMUNICATION AND NETWORKS VIDEO THIS VIDEO CONTENT PDF LINK :