
- C Programming Tutorial
- C - Home
- C - Overview
- C - Environment Setup
- C - Program Structure
- C - Basic Syntax
- C - Data Types
- C - Variables
- C - Constants
- C - Storage Classes
- C - Operators
- C - Decision Making
- C - Loops
- C - Functions
- C - Scope Rules
- C - Arrays
- C - Pointers
- C - Strings
- C - Structures
- C - Unions
- C - Bit Fields
- C - Typedef
- C - Input & Output
- C - File I/O
- C - Preprocessors
- C - Header Files
- C - Type Casting
- C - Error Handling
- C - Recursion
- C - Variable Arguments
- C - Memory Management
- C - Command Line Arguments
- C Programming useful Resources
- C - Questions & Answers
- C - Quick Guide
- C - Useful Resources
- C - Discussion
C Program to Check Armstrong Number?
A number is called an Armstrong number if the sum of cubes of digits of the number is equal to the number itself. It is a mathematical concept usually used in programming to build basic logic of the programmer
Input:370 Output:370 is an Armstrong Number
Explanation
370 = 3*3*3 + 7*7*7 + 0*0*0 = 27 + 343 + 0 = 370
Example
include <iostream> using namespace std; int main() { int n, num, rem, sum = 0; cin >> n; num = n; while(num != 0) { digit = num % 10; sum += digit * digit * digit; num /= 10; } if(sum == n) printf("%d is an Armstrong number.", n ); else printf("%d is not an Armstrong number.",n); return 0; }
- Related Articles
- C++ Program to Check Armstrong Number
- Python Program to Check Armstrong Number
- Java Program to Check Armstrong Number
- Swift Program to Check Armstrong Number
- Golang Program to Check For Armstrong Number
- Write a C# program to check if the entered number is Armstrong number?
- Java Program to Check Armstrong Number between Two Integers
- Haskell program to check armstrong number between two integers
- Kotlin Program to Check Armstrong Number between Two Integers
- C# Program to Check Whether the Entered Number is an Armstrong Number or Not
- Java program to check whether the given number is an Armstrong number
- Check the number is Armstrong or not using C
- C++ Program to Display Armstrong Number Between Two Intervals
- How to Check Armstrong Number between Two Integers in Golang?
- Java Program to Display Armstrong Number Between Two Intervals

Advertisements