Question

Write three functions, float getNum(), float add(float, float), void outSum(float); that asks user for two numbers,...

Write three functions, float getNum(), float add(float, float), void outSum(float); that asks user for two numbers, finds the sum of two numbers, and displays the sum repeatedly in a main program until the user enter "0" for either one of the numbers. (In C++)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

float getNum(){
    float n;
    cout<<"Enter a number: ";
    cin>>n;
    return n;
}

float add(float a, float b){
    return a+b;
} 

void outSum(float f){
    cout<<"Sum: "<<f<<endl;
}

int main()
{
    outSum(add(getNum(),getNum()));
    return 0;
}

Output:

Enter a number: 4.5 Enter a number: 6.7 Sum: 11.2

Add a comment
Know the answer?
Add Answer to:
Write three functions, float getNum(), float add(float, float), void outSum(float); that asks user for two numbers,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT