0 votes
122 views
in C programming by (98.9k points)
edited
C Program to Check Armstrong Number

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
#include <conio.h>
 
int main(){
    int number, sum = 0, lastDigit, temp;
    printf("Enter a number : ");
    scanf("%d", &number);
    temp = number;
     
    while(temp != 0){
        lastDigit = temp%10;
        sum = sum + (lastDigit*lastDigit*lastDigit);
        temp = temp/10;
    }
     
    if(sum == number){
        printf("%d is Armstrong Number \n", number);
    } else {
        printf("%d is not an Armstrong Number \n", number);       
    }
    getch();
    return 0;
}

 

Related questions

0 votes
1 answer 139 views
0 votes
1 answer 157 views
0 votes
1 answer 124 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 133 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 114 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

554 users

...