'i' undeclared (first use in this function)

0

Mam taki programik i wywala mi błędy :

#include <stdio.h>
#include <conio.h>
int main()
{
    int st[5];

    for (int i = 0; i < 5; i++) {
        printf("Nr %d podaj stopien : ", i);
        scanf("%d", &st[i]);
    }
    int j = 0;
    int max = st[0];
    for (i = 0; i < 5; i++)
        if (st[i] > max)
            j = i;
    printf("\nNajlepszy jest uczen nr %d i jest to %d", j, st[j]);
    getche();
    return 0;
}

Błędy :
[Error] 'i' undeclared (first use in this function)
[Note] each undeclared identifier is reported only once for each function it appears in

1

W tej pętli

for (i=0; i<5; i++)

Używasz niezadeklarowanej zmiennej i.

Wystarczy zmienić tą pętlę na

for (int i = 0; i < 5; i++)

1 użytkowników online, w tym zalogowanych: 0, gości: 1