#include <iostream>
usingnamespace std;
int main()
{
int n, value, sum=0;
cout << "Please enter positive number greater than 0, less than or equal to 100." << endl;
cin >> n;
int max = 0;
int min = 1;
while(n<0 || n>100)
{
cout << "Incorrect" << endl;
cout << "Please try again." << endl;
cin >> n;
}
for (int i=0; i<n; i++)
{
cout << "Enter value number " << i+1 << endl;
cin >> value;
if(max<value)
{
max = value;
}
elseif (min<value)
{
min = value;
}
sum += value;
}
cout << "The total sum is: " << sum << endl;
cout << "The max is: " << max << endl;
cout << "The min is: " << min << endl;
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int n, value, sum=0;
cout << "Please enter positive number greater than 0, less than or equal to 100." << endl;
cin >> n;
int max = 0;
int min = 100;
while(n<0 || n>100)
{
cout << "Incorrect" << endl;
cout << "Please try again." << endl;
cin >> n;
}
for (int i=0; i<n; i++)
{
cout << "Enter value number " << i+1 << endl;
cin >> value;
if(max<value)
{
max = value;
}
elseif (min>value)
{
min = value;
}
sum += value;
}
cout << "The total sum is: " << sum << endl;
cout << "The max is: " << max << endl;
cout << "The min is: " << min << endl;
return 0;
}
It outputs this:
Please enter positive number greater than 0, less than or equal to 100.
3
Enter value number 1
1
Enter value number 2
2
Enter value number 3
3
The total sum is: 6
The max is: 3
The min is: 100