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;
Comments
Leave a comment