Date: Mon, 11 Nov 1996 17:12:42 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Mon, 30 Sep 1996 00:31:12 GMT Content-length: 3280
#include<iostream.h> int main() { int counter = 3, value = 2; while (counter < 7) { value = value * 2; cout << "Value is " << value << endl; if ((counter % 2) == 0) { cout << "Counter is " << counter << endl; } counter++; } }Answer:
Value is 4 Value is 8 Counter is 4 Value is 16 Value is 32 Counter is 6
So for example, using your function, I could write the following code segment:
int viking_score, packer_score; // 3 Touchdowns, 3 field goals, 3 extra points viking_score = calculate_score(3, 3, 3); // 3 Touchdowns, 0 field goals, 3 extra points packer_score = calculate_score(3, 0, 3); if (viking_score > packer_score) { cout << "Vikings win." << endl; } else if (packer_score < viking_score) { cout << "Packers win." << endl; } else { cout << "Tie game." << endl; }Write your code for the function below:
int calculate_score(int td, int fg, int ep) { return ((td * 6) + (fg * 3) + ep); }