I need help..

How can I initialize a variable if the result may be even smaller than 0?
for example I want to find the max value between these numbers: -10 -2 -8
during writing the code I have to initialize "max",so how can I do that because it can't be initialized as 0..

closed account (EwCjE3v7)
Sorry you have provided us with really little information(which I do sometimes to) and we can't help you as we do not know what you are talking about. Please try providing the code as well as more information. Thanks cheers
If you are trying to find the highest value in an array than this is how you do it. Remember this process if this is what you are trying to do.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include<iostream>

using namespace std;

int main()
{
	int array[]={-10,-2,-8};
	int highest;
	highest=array[0];
	for(int i=1;i<3;i++)
	{
		if(array[i]>highest)
	    highest=array[i];
	}
	cout<<highest;
	
	
	
}
Topic archived. No new replies allowed.