Code:
#include <stdio.h>
int main() {
int count, input, temp, max;
printf("How many: ");
scanf("%d", &count);
printf("Enter %d inputs: ", count);
for (int i = 0; i < count; ++i) {
scanf("%d", &input);
if(input > temp){
max = input;
}
temp = input;
}
printf("Max = %d", max);
return 0;
}
I've wrote some code that enters 'x' amount of variables and determines which is the largest number to output. But I'm having issues with negative numbers and don't understand why.
for example: I input -2 -5 -10 and the output is 69.
All effort is appreciated.
Thanks,
Nand