Sample solution int userVal; cout << "Please enter an integer value" << endl; cin >> userVal; cout << "You entered " << userVal << endl; |
Sample solution R = N % D; |
Sample solution cout << setiosflags(ios::fixed); // the following also works: cout << fixed; cout << setprecision(3); cout << setw(12) << x << endl; cout << setw(12) << y << endl; cout << setw(12) << z << endl; |
Sample solution f = sqrt(pow(a, b) + pow(c, d)); |
Sample solution #include <iostream> using std::cout; using std::endl; using std::cin; int main() { float userVal; // could use double instead cout << "Please enter a number: "; cin >> userVal; cout << "Your value was " << userVal << endl; // the sample solution shows a couple of computation approaches, either is fine cout << "The square of that is " << (userVal*userVal) << endl; cout << "And the cube of your value is " << pow(userVal, 3) << endl; } |