'While loop not stopping in C programmming

    int math=0,phy=0,che=0,avg=0,cprg=0,n,i=1,sum=0,large;
    char name, roll_no, dept;
    printf("\n How many students : ");
    scanf("%d", &n);
    
    while(i<=n)
     {
        printf("NAME : ");
        scanf("%s", &name);
        printf("DEPARTMENT :");
        scanf(" %s", &dept);
        printf("ROLL NUMBER :");
        scanf("%s", &roll_no);  
        printf("☻ MATHS MARK :");
        scanf(" %d", &math);
        printf("☻ PHYSICS MARK : ");
        scanf("%d", &phy);
        printf("☻ CHEMISTRY MARK :");
        scanf(" %d", &che);
        printf("☻ C Programming :");
        scanf(" %d", &cprg);
        printf("\n");
        avg = math+phy+che+cprg;
        avg=avg/4;
        append(&head, avg);
        i++;
    }
    return 0;
}

Here is some of my code. I need to run this loop for the number of times the user enters in the input, and the loop is not ending in VS Code even though it works fine in online GDB.

c


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source