Algorithms_in_C++ 1.0.0
Set of algorithms implemented in C++.
|
Program to check if a number is an Armstrong/Narcissistic number in decimal system. More...
#include <cassert>
#include <cmath>
#include <iostream>
Functions | |
int | number_of_digits (int num) |
bool | is_armstrong (int number) |
void | test () |
int | main () |
Program to check if a number is an Armstrong/Narcissistic number in decimal system.
Armstrong number or Narcissistic number is a number that is the sum of its own digits raised to the power of the number of digits.
bool is_armstrong | ( | int | number | ) |
Function to check whether the number is armstrong number or not.
num | Number |
true
if the number is armstrong. false
if the number is not armstrong. int main | ( | void | ) |
int number_of_digits | ( | int | num | ) |
Function to calculate the total number of digits in the number.
num | Number |
void test | ( | ) |
Function for testing the is_armstrong() function with all the test cases.