Онлайн компилятор C

#include <stdio.h> int main() { int n; scanf("%d", &n); int max, min; for (int i = 0; i < n; i++) { int num; scanf("%d", &num); if (i == 0) { max == num; min == num; } else { if (max > num) ; max = num; if (min < num) ; min = num; } } return 0; }
This code reads an integer n, then reads n more integers, and attempts to find the maximum and minimum among them. However, it has several errors that prevent it from working correctly.

- The assignment operator is `=`, not `==`. In the lines `max == num;` and `min == num;`, you are using the comparison operator instead of assignment, so max and min are never set to the first number.
- After the `if` conditions on lines like `if (max > num) ;`, there is an empty statement (the semicolon), and then `max = num;` runs unconditionally. This means max is always set to the current number, regardless of whether it is larger. The same issue occurs for min.
- The program does not print the results, so even if the logic were correct, you would not see the output.