Armstrong Number

#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!

Comments (0)

  • To add your comment please or

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.

Got It!