quotient = numerator / denominator; remainder = numerator % denominator;
user inputs | expected output | ||
numerator | denominator | quotient | remainder |
17 | 5 | 3 | 2 |
11 | 13 | 0 | 11 |
12 | 4 | 3 | 0 |
std::cout << std::setw(ColWidth) << numerator << std::endl; std::cout << std::setw(ColWidth) << denominator << std::endl; std::cout << std::setw(ColWidth) << userInitial << std::endl; std::cout << std::setw(ColWidth) << "And this!" << std::endl;
std::cout << std::setiosflags(std::ios::fixed); std::cout << std::setprecision(5);
double third = 1/3.0;
std::cout << Pi << std::endl; std::cout << third << std::endl;
double xVal, yVal; // two values to be supplied by the user double answer; // location where we'll store the result of our call std::cout << "Enter two numeric values:" << std::endl; std::cin >> xVal >> yVal; answer = rootOfSumSquares(xVal, yVal); std::cout << "For inputs " << xVal << " and " << yVal; std::cout << ", the root of the sum of their squares is "; std::cout << answer << std::endl;
double rootOfSumSquares(double x, double y) { double sumSqs; // will hold the sum of the two squares double root; // will hold the root of the sum of the squares (our final answer) sumSqs = x*x + y*y; root = sqrt(sumSqs); return root; }
// sample structure for a program with its own functions foo and blah #includes and constants // prototypes int foo(double a, int b, float c); double blah(int m) // main routine int main() { ... main's code ... } // full versions int foo(double a, int b, float c); { ... foo's code ... } double blah(int m) { ... blah's code ... } |
Estimated weekly hours: Daphne: 25.5 Fred: 5.7 Velma: 98.2 Unanswered: 38.7
Welcome to EvelKall Monitoring! We estimate your staff's working hours based on the results of weekly call samples. At the moment it assumes you have 3 staff members, and rounds results to the nearest 0.1 hours. Please enter the name of the first employee (as a single word): Daphne Please enter the name of the second employee (as a single word): Fred Please enter the name of the third employee (as a single word): Velma Please enter the number of times Daphne answered a call: 27 Please enter the number of times Fred answered a call: 6 Please enter the number of times Velma answered a call: 104 Please enter the number of times a call was unanswered: 41 Based on the information you provided, we have the following results: Estimated weekly hours: Daphne: 25.5 Fred: 5.7 Velma: 98.2 Unanswered: 38.7 (Note that results may not equal exactly 168.0 due to output rounding.) Thanks for using EvelKall Monitoring! |