Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

An Armstrong number x is a number that the sum of the cube of its digits is equal to this number. For instance, 1 5

An Armstrong number x is a number that the sum of the cube of its digits is equal to this number. For instance, 153 and 371 are Armstrong numbers, since
153=13+53+33 and 371=33+73+13. However, 127 and 234 are not Armstrong numbers since they are not equal to 13+23+73 and 23+33+43, respectively.
Write a C program that scans from the user a 3-digit integer x and implements a function bool isArmstrong(x) which checks whether x is an Armstrong number and
return true or false.
Note: To use variables of type bool, you need to add #include .
To use the pow function from Math library, you need to include the following #include header and then call the function pow(a, b) that returns ab.
To compile, use the following: gcc -o problem3 problem3.c -lm.
Sample input/output 1: (input highlighted in bold)
Please enter a positive 3-digit integer: -222
The number should not be negative
Sample input/output 2: (input highlighted in bold)
Please enter a positive 3-digit integer: 18
The number should be a positive 3-digit integer
Sample input/output 3: (input highlighted in bold)
Please enter a positive 3-digit integer: 1100110
The number should be a positive 3-digit integer
Sample input/output 4: (input highlighted in bold)
Please enter a positive 3-digit integer: 188
188 is not an Armstrong number
Sample input/output 5: (input highlighted in bold)
Please enter a positive 3-digit integer: 371
371 is an Armstrong number

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago