Sample solution // I'm assuming the using std::cin, cout, etc has been done float initialVal; cout << "Please enter a value" << endl; cin >> initalVal; cout << "You entered " << initialVal << endl; |
Sample solution rem = num % denom; |
Sample solution // this question should have said fixed instead of cin in the "... that uses ..." // so I didn't take marks off if folks neglected the << fixed part of the answer below // Here assuming the using std::cin, cout, etc has been done // note that setw has to be done for each columnized value, // whereas fixed and setprecision need only be done once cout << fixed << setprecision(2); cout << setw(10) << price1 << endl; cout << setw(10) << price2 << endl; cout << setw(10) << price3 << endl; |
Sample solution w = pow(x,y) + sqrt(z); |
Sample solution #include <iostream> using std::cin; using std::cout; using std::endl; int main() { double userVal; cout << "Please enter a real number" << endl; cin >> userVal; double twice, thrice; twice = 2 * userVal; thrice = 3 * twice; cout << "Twice original is " << twice << endl; cout << "Three times that value is " << thrice << endl; return 0; } |