```
//Problem Description:
//Write an C++ Program (namely PQ1.cpp) to
//input several (zero or more, depending on users) integers,
//and output their sum and maximum and second largest value.
//Michael Roland
//August 29, 2005
//PG2.cpp
//Selection and Repetion control structures
#include <iostream>
using namespace std;
const int SENTINEL = -100;
int main()
{
int num;
int sum = 0;
int counter = 0;
int max;
int max2;
cout<<"Enter the number of users "<<endl;
cout<<"If you're enter the amount of users then enter"<<SENTINEL<<endl;
cin>>num;
max=num;
max2=num;
while(num != SENTINEL)
{
sum = sum + num;
counter++;
cin>>num;
if (num > max)
{
max2 = max;
max = num;
}
else if (num > max2)
{
max2 = num;
}
}
cout<<"The sum of the "<<counter<<" users is "<<sum<<endl;
cout<<"The max number is "<<max<<endl;
cout<<"The second largest number is "<<max2<<endl;
return 0;
}
/*
ascending order
Enter the number of users
If you're enter the amount of users then enter-100
1
2
3
4
5
-100
The sum of the 5 users is 15
The max number is 5
The second largest number is 4
Press any key to continue
descending order
negative numbers
Enter the number of users
If you're enter the amount of users then enter-100
5
4
3
2
1
-100
The sum of the 5 users is 15
The max number is 5
The second largest number is 5
Press any key to continue
zero, negative, and positive
Enter the number of users
If you're enter the amount of users then enter-100
4
-2
33
-44
0
-100
The sum of the 5 users is -9
The max number is 33
The second largest number is 4
Press any key to continue
*/
```