Answer to Question #33155 in C++ for Ha Na Choi

Question #33155
Write a C++ program which reads values for two floats and outputs their sum, product and quotient. Include a sensible input prompt and informative output.
1
Expert's answer
2013-07-16T09:52:59-0400
#include <iostream>


using namespace std;


int main(){
float a, b;
cout << "Input two numbers: ";
cin >> a >> b;


cout << "Sum is: " << a + b << endl;
cout << "Product is: " << a * b << endl;
if( b != 0 ) cout << "Quotient is: " << a / b << endl;
else cout << "Division by zero" << endl;


return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS