Computer Science, asked by udaysinghus1217, 9 months ago

Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of
three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For
example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.

Answers

Answered by dreamrob
5

Program in C++:

#include<iostream>

#include<math.h>

using namespace std;

int main()

{

int n;

cout<<"Enter a number : ";

cin>>n;

int count = 0;

int n1 = n;

while(n1 != 0)

{

 count++;

 n1 = n1 / 10;

}

n1 = n;

int sum = 0;

while(n1 != 0)

{

 int d = n1 % 10;

 sum = sum + (int)pow(d, count);

 n1 = n1 / 10;

}

if(sum == n)

{

 cout<<"Armstrong number";

}

else

{

 cout<<"Not an armstrong number";

}

return 0;

}

Output:

Enter a number : 371

Armstrong number

Attachments:
Similar questions