C++ problem

Write a program that prompts the user to enter two positive integers lower and upper, then finds and prints all numbers in the interval [lower, upper] that have the property that the cube sum of the digits equals the number itself. The program also prints the how many numbers have the cube sum property.
2 answers Last reply
More about problem
  1. #include<iostream>
    using namespace std;
    void "insert function name" (int lower, int upper){
    int i,n;
    n=0;
    for(i=lower;i<=upper;i++){
    if(digitcubesum( i )==i){
    n++;
    cout<<i<<endl;
    }
    }
    cout<<"this many numbers completed the trial of fire"<<n<<endl;
    }
    int digitcubesum(int n){
    int result=0;
    int i;
    i=n;
    while(i>0){
    result+=i%10;
    i=i/10;
    }
    return result*result*result;
    }

    int main(){
    int lw,up;
    cout<<"Insert numero uno"<<endl;
    cin>>lw;
    cout<<"Insert number two"<<endl;
    cin>>up;
    "insert name of your primary function, same as above"(lw,up);
    return 0;
    }
  2. Please do your own homework.
Ask a new question

Read More

Programming Apps