Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the following C++ assignment that computes the largest and second largest

ID: 3749457 • Letter: W

Question

Write the following C++ assignment that computes the largest and second largest integer using while, if and else loops. Do not use arrays. Here is an example of the print after the user has entered ten numbers:

Enter the first number: 0

Enter the next number: -1

Enter the next number: 25

Enter the next number: -44

Enter the next number: -55

Enter the next number: -66

Enter the next number: -7

Enter the next number: -8

Enter the next number: -9

Enter the next number: -10

The largest number is 25

The second largest number is 0

Press any key to continue . . .

Explanation / Answer

#include using namespace std; int main() { int max2, max, num; cout > max; cout > max2; if(max num; if(num > max) { max2 = max; max = num; } else if(num > max2) { max2 = num; } } cout