Loops and Iteration Structure






****Please Help...edit the program, complete the blanks***
Last edited on
Here is the answer, though giving you the solution won't help you pass the class:
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
#include <iostream> 
using namespace std; 

int main() 
{ 
    unsigned long int number; 
    unsigned int sumOfCubes = 0; 
    int digit; 

    cout << "Please enter an integer number: "; 
    cin >> number; 

    while( number > 0 ) 
    { 
        digit = number % 10; 

        sumOfCubes = sumOfCubes + digit*digit*digit; 

        number = number / 10 ; 
    } 

    cout << "The sum of the cube of the digits is " << sumOfCubes << endl; 

    return 0; 
} 
Topic archived. No new replies allowed.