

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Check the number is Armstrong or not using C
Problem
How to check whether the given number is an Armstrong number or not using C Programming language?
Solution
Armstrong number is the number that is equal to the sum of cubes of its digits.
Syntax
pqrs………=pow(p,n)+pow(q,n)+pow(r,n)+……….
For example, 153,371,1634, etc., are Armstrong numbers.
153=1*1*1 + 5*5*5 + 3*3*3 =1+125+27 =153 (Armstrong number)
Program
#include<stdio.h> int main(){ int number,remainder,total=0,temp; printf("enter the number="); scanf("%d",&number); temp=number; while(number>0){ remainder=number%10; total=total+(remainder*remainder*remainder); number=number/10; } if(temp==total) printf("This number is Armstrong number"); else printf("This number is not Armstrong number"); return 0; }
Output
enter the number=371 This number is Armstrong number Check: 371=3*3*3 +7*7*7 + 1*1*1 =27 + 343 +1 =371 enter the number=53 This number is not Armstrong number
Explanation
53 = 5*5*5 + 3*3*3 =125 +27 = 152 != 53
- Related Questions & Answers
- C# Program to Check Whether the Entered Number is an Armstrong Number or Not
- C++ Program to Check Armstrong Number
- C Program to Check Armstrong Number?
- Write a C# program to check if the entered number is Armstrong number?
- Check if a number is jumbled or not in C++
- Check if a number is an Unusual Number or not in C++
- Check if a number is a Krishnamurthy Number or not in C++
- Check if a number is an Achilles number or not in C++
- Program to check whether the given number is Buzz Number or not in C++
- Java program to check whether the given number is an Armstrong number
- Check if the given number is Ore number or not in Python
- Check whether the given number is Euclid Number or not in Python
- C# Program to check if a number is prime or not
- C++ Program to Check Whether a Number is Prime or Not
- C++ Program to Check Whether a Number is Palindrome or Not
Advertisements