C Programming
Armstrong Number
Learn c programming for checking user given number is armstrong or not
By Geekboots
5/20/2018
0 views
armstrong-number.cC
#include<stdio.h>
int main() {
int no, i, mod, ans;
printf("Check the given number is armstrong or not\n");
printf("Enter a number:\n");
scanf("%d", &no);
i = no;
/* Loop the process using "while loop" */
while(i != 0) {
mod = i % 10;
ans += (mod * mod * mod);
i = i / 10;
}
if(ans == no)
printf("It's a Armstrong Number!\n");
else
printf("It's not a Armstrong Number!\n");
return 0;
}
/* Output */
Check the given number is armstrong or not
Enter a number:
153
It's a Armstrong Number!
/* ---------------------------------------- */
Check the given number is armstrong or not
Enter a number:
168
It's not a Armstrong Number!
c languagec programmingc coding for Armstrong numberarm strong number in c