Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void ArmStrongNumberCheck(int input)
- {
- string tempStr = to_string(input);
- int digits = tempStr.size();
- digits;
- double sum = 0;
- for(int i =0; i< digits;i++)
- {
- int tempNumber = tempStr.at(i) - 48;
- sum = sum + pow(tempNumber, digits);
- }
- cout << sum << endl;
- if(sum == input)
- {
- cout << "True" << endl;
- }
- else
- {
- cout << "False" << endl;
- }
- }
- int main()
- {
- int input = 153;
- ArmStrongNumberCheck(input);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement