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

#include <stdio.h> int main() { int sum,a,b,c; scanf("%d",&sum); a=sum/100; b=sum%100/10; c=sum%10; max=a; if(b>=max)max=b; if(c>=max)max=c; printf("%d",max); return 0; }
This code reads a three-digit integer, extracts its hundreds, tens, and units digits, then finds and prints the largest digit among them.

- The variable `max` is used before it is declared. In C, you must declare all variables before using them. Move the declaration of `max` to the line where `a`, `b`, and `c` are declared.
- The logic for finding the maximum digit is correct, but the variable `max` is not initialized before the first comparison. Make sure `max` is assigned an initial value, such as `a`, before the `if` statements.