Filled Under: ,

C Program to Check Armstrong Number


C Program to Check Armstrong Number

C Program to Check Armstrong Number

 In this program, I have discussed about the C program to check armstrong number. this program is solely made for 3 digit armstrong numbers.

#include<stdio.h>
{int main()
    {int s=0;k,n,r;
printf("Enter a number");
scanf("%d",&n);
k=n;
        while(n>0)
        { r=n%10;
            s=s+r*r*r;
            n=n/10;}
            if(k==s)
            {printf("Armstrong Number");}
            else
            {printf("Not Armstrong Number");
            }
        }
    }

Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

0 comments:

Post a Comment

 

Copyright 2020 Programming in C All Right Reserved