Sample solution float firstNum; cout << "Please enter a number: "; cin >> firstNum; cout << "You entered " << firstNum << endl; |
Sample solution rem = numer % denom; |
Sample solution cout << setiosflags(ios::fixed); // the following also works: cout << fixed; cout << setprecision(4); cout << setw(10) << a << endl; cout << setw(10) << b << endl; cout << setw(10) << c << endl; |
Sample solution v = sqrt(pow(w, x) + pow(y, z)); |
Sample solution #include <iostream> using std::cin; using std::cout; using std::endl; int main() { int userVal; // could use long instead cout << "Please enter an integer: "; cin >> userVal; cout << "You entered " << userVal << endl; // the sample solution shows a couple of different computation techniques, either is fine cout << "The square of that is " << (userVal*userVal) << endl; cout << "The cube of that is " << pow(userVal, 3) << endl; } |