Check Armstrong Number

Armstrong Number

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

 Armstrong Number
Armstrong Number

Write a C program to Armstrong Number

PROGRAM: Armstrong Number

/* Check Armstrong Number */

#include<stdio.h>
int main()
{
    int n, sum = 0, t, r;

    printf(“Please enter a number: “);       
    scanf(“%d”,&n);

    for(t=n;t>0;t=t/10)
    {
        r = t%10;
        sum = sum + r*r*r;
    }
     if ( n == sum )
        printf(“%d is an armstrong number.”,n);
    else
        printf(“%d is not an armstrong number.”,n);

    return 0;

}

Leave a Reply

Your email address will not be published. Required fields are marked *