hello guys.. i wish u could help me with this program.
Write a cplusplus programs that reads an integer as lng as they continue to be input in increasing order,that is each coming number must be a greater than or egual to the previous. as soon as the sequence is no longer increasing the program should stop and output the following:
1.how many numbers were entered <not including the last number)
2. the sum of the entered numbers(not including the last number)
3. the minimum,maximum,and average of the entered numbers(not including the last number).
a sample execution
enter a number:2
enter a number:5
enter a number:7
enter a number:0
stopped.
increasing count=3
sum=14
min=2
max=7
avg=4.666
my code is : (put its not complete i need help.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
int x,count=0,max,min,av,num;
do{
cout<<"enter a number"<<endl;
cin>>num;
count=count+1;
while (num>x)
cout<<"enter a number"<<endl;
else
av=sum/count;
cout<<av;
}
return 0;
}
i stuck..!!!
need help.. i wish also to write using while.. not do while
You need to remove the space in this statement using name space std; the else on line 12 should not be there. You need a ; at the end of this statement while (num>x). This is not how you use cout av=sum/cout; cout should look like this cout << "Hello World!" << endl; The brace on line 15 should be matched with } while(num>x)