I have the following code:
#include <stdio.h>
int main()
{
int student = 1;
float mark, total = 0;
while (mark != -1.00) {
printf("Enter marks for Student %d (or -1 to stop): ", student);
scanf("%f", &mark);
total += mark;
student++;
}
return 0;
}
When I try to compile it with gcc -O -Wall main.c
I get the warning:
main.c: In function ‘main’:
main.c:8:17: warning: ‘mark’ is used uninitialized [-Wuninitialized]
8 | while (mark != -1.00) {
| ~~~~~^~~~~~~~
main.c:6:11: note: ‘mark’ declared here
6 | float mark, total = 0;
|