Write a C Program to Check a number is Armstrong or not



Armstrong Number, Sumit Kar, Timus Rak



#include<stdio.h>

void 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);









}


Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C