Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Post Top Ad

Your Ad Spot

Sunday, July 31, 2022

C program to check whether the input digit is Armstrong or not

 C program to check whether the input digit is Armstrong or not


(An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3^3+7^3+1^3=371)


#include<stdio.h>

#include<conio.h>

main()

{

            int num,n,sum=0,d;

            printf("Enter any number\n");

            scanf("%d",&n);

            num=n;

            do{

                        d=n%10;

                        sum=sum+d*d*d;

                        n=n/10;

            }while(n>0);

            if(sum==num)

printf("Armstrong number\n");

            else

            printf("Not Armonstrong number\n");

getch();

}

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages