### small prob

I have this problem in this code
my problem in min value !!

and i want to count the values but when the value is bigger than 50 !!

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374`` ``````#include using namespace std; int main() { double value,min,max,avg,sum; int count; int Degree; count=0; min=0.0; max=0.0; sum=0.0; cout<<"put your value ^_^ ,if you want stope put -1 like a value please "<>value; while(value!=-1)//if you want stope put -1 like a value please { sum +=value; count++;//for count the value if(value>max) max=value; else if((value0))// have a problem here min=value; cin>>value; } cout<<" the max value is : "<>Degree; if(Degree>=avg) cout<<"pass"<
?? please it's in min only !
As far as I understood about your problem, it's about min value. If so, you could do following:
put this code in line 20

 ``12`` `````` while(value < 0) cin >> value; min = value;``````

And replace below code with the code snip of line 33

`else if((value < min) && (value > 0))`
Last edited on
mmmm no that's wrong

it give me 0 !!

because that's the initializes value !!
i dont know if i understood right but :
`else if((value<max)&&(value>0))// have a problem here `
if you want the minimum value then dont initialise min with 0. initialise it with the first value you read:(also for max)
 ``123456`` ``````cout<<"put your value ^_^ ,if you want stope put -1 like a value please "<>value; //HERE min=value;max=value; ``````

and in your code test for
 ``12345`` ``````if(value>max) max=value; else if (value
Last edited on
I normally like to assign min and max to the first value read so after you read the first value on line 18 add
 ``12`` ``````min = value; max = value;``````

Also you should be checking min and max separately without the else.

 ``1234`` ``````if(value >= max) max = value; if(value <= min) min = value;``````

ok i will try it ,

but what about the second question ( the count ) !!
What do you suggest, sounds fairly easy to me?
I don't know how much skill do you have about C++ and why even can't run a code. But my code wasn't wrong. The min will be initialized with first value you input. Then next values will be tested whether is each one bigger or smaller and ...
oh am sorry am already change the all code and it's right ^_^ thx for all
Topic archived. No new replies allowed.