Just a couple of things in your code. I would recommend that you indent the code, as well.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
#include <iostream>
using namespace std;
main() // It should be int main()
{
int l,count,sum,average,minimum,maximum,n;
cout<<"how many times loop run plz enter";
cin>>l;
for(n=0,count=1;count<=l;count++) // Wrong format of for loop. It should have not more // than three arguments. Example for (int x = 0; x < l ; x++)
{
cout<<"plz enter the first" <<count<<"value";
cin>>n;
}
}
|
Proposed Pseudocode to give you an idea.
Declare the variables.
Ask the user to input the max numbers of integers in the loop to add.
Run a for loop, which does not exceed the number the user inputted.
For each number the user enter, establish a running total for the sum variable.
If the number is less than the minimum value, then the number is the minimum value.
Record the position of the minimum value
If the number is higher than the maximum value, then the number is the maximum value.
Record the position of the maximum value
Calculate the average by dividing the sum variable divide by the max number of integers in the loop to add.
Notify the user the sum of the integers
Notify the user the average of the numbers
Notify the maximum number to the user and its position
Notify the minimum number to the user and its position
I wrote the code (I am not going to give it away, though) and to show you the output it below.
Input the maximum number of loops to add: 6
Enter integer number 1 :88
Enter integer number 2 :22
Enter integer number 3 :55
Enter integer number 4 :66
Enter integer number 5 :1
Enter integer number 6 :99
The sum of the numbers is 331
The average of the numbers is 55
The maximum number is 99 at position number 6
The minimum number is 1 at position number 5 |