Answer to Question #342884 in C++ for Padi

Question #342884

Find the error(s) in each of the following program segments and explain how the error(s) can be corrected:

(v) void theProduct() { int a; int b; int c; int result; cout << “Enter three integers “ << endl; cin >> a >> b >> c; result = a * b * c; cout << “Result is “ << result << endl; return result; }


1
Expert's answer
2022-05-23T15:18:15-0400
#include <iostream>
void theProduct(){    // int instead of void or if you want to return value
    using namespace std; // define namespace or std::cout, std::cin, std::endl
    int a; int b; int c;
    int result;
    cout <<"Enter three integers"<< endl;
    cin >> a >> b >> c;
    result = a * b * c; 
    cout << "Result is"<< result << endl;
//    return result; void type returns nothing
    
}

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