Armstrong or not in C


In this example, you will learn to check whether an integer entered by the user is an Armstrong number or not.

Source Code

/*
Three digit number input through the keyboard write a program
to find the given number is Armstrong number or not.
 
*/
 
#include<stdio.h>
 
int main()
{
    int n,a,d1,d2,d3;
    printf("\nEnter 3 Digit No : ");
    scanf("%d",&n);//153
    d3=n%10;//3
    a=n/10;//15
    d2=a%10;//5
    d1=a/10;//1
    //printf("%d   %d   %d",d1,d2,d3);
    a=(d1*d1*d1)+(d2*d2*d2)+(d3*d3*d3);
    if(a==n)
    {
        printf("%d is an armstrong number",n);
    }
    else
    {
         printf("%d is not an armstrong number",n);
    }
    return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes