Ask Question

A variable like user_num can store a value like an integer. Extend the given program as indicated. Output the user's input. (2 pts) Output the input squared and cubed. Hint: Compute squared as user_num * user_num. (2 pts) Get a second user input into user_num2, and output the sum and product. (1 pt)

+4
Answers (1)
  1. 26 January, 00:38
    0
    The answer to this question is given below in the explanation section. It is noted that this program is written in C+ + using online C+ + compiler.

    Explanation:

    #include

    using namespace std;

    int squared (int num) / / this is the function to compute square

    {

    return num*num;

    }

    int cube (int num) / / this is the function to compute cube

    {

    return num*num*num;

    }

    int main ()

    {

    int user_num, user_num2; / / variable declaration

    cout<<"Enter the first number: "; //prompt user to enter the number

    cin>>user_num; //store the user entered number into variable

    cout<<"/nEnter the second number: "; //prompt the user to enter the second number

    cin>>user_num2; //store the user entered number into variable

    cout<<"/nSquared of first number is: "<
    cout<<"/nCube of first number is: "<
    cout<<"/nSquare of second number is: "<
    cout<<"/nCube of second number is: "<
    cout<<"/nSum of number 1 and number 2 is: "<
    cout<<"/nProduct of number 1 and number 2 is: "<
    return 0; //terminate the program

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A variable like user_num can store a value like an integer. Extend the given program as indicated. Output the user's input. (2 pts) Output ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers