C++ Problem

If/Else Homework
A “magic” number is an integer in which the number is equal to the sum of the cubes of its digits. Write a program to determine whether a three digit number entered by the user is a magic number.

I have started on this but I do not know how to continue! Please give me hints or tips!
1
2
3
4
5
6
7
8
9
10
#include <iostream>
#include <cmath>
using namespace std;
int main () {
	int x,y,z;
	         cout<<"Input the first digit of the 3 digit number: " ;
		cin>>x;
		     cout<<"Input the second digit of the 3 digit number: ";
		cin>>y;
			cout<<"Input the third digit of the 3 digit number: ";
Here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int manual()
{
    int set[256];
    int size = 0;
    int relay = 0;
    int total = 0;
    int number = 0;

    cout << "Enter how many digits are in number: ";
    cin >> size;
    cout << "Enter number: ";
    cin >> number;

    for(int relay2 = 0;relay2 < size;relay2++)
    {
        cout << "Next digit: ";
        cin >> relay;
        set[relay2] = relay;
    }

    for(int relay3 = 0;relay3 < size;relay3++)
    {
        relay = set[relay3];
        relay = relay * relay * relay;
        total += relay;
    }

    if(total == number)
    {
        cout << number << " is a magic number!" << endl;
    }
    else
    {
        cout << number << " is not a magic number." << endl;
    }
    system("PAUSE");
    return 0;
}

int main(int nNumberofArgs, char* pszArgs[])
{
    char input;

    cout << "Welcome to magic number finder! Enter 'M' to find out if your number is magic. Enter 'A' to abort: ";
    cin >> input;

    switch(input)
    {
        case 'm':
        case 'M':
        manual();
        break;
        case 'a':
        case 'A':
        return 0;
        break;
        default:
        cout << "M or A. How hard is it?" << endl;
        return 0;
    }
}
Hey double posts, the above works or I posted the solution in your other thread about this exact same topic: http://www.cplusplus.com/forum/beginner/92086/
Topic archived. No new replies allowed.