The code works for every if statement except for the first one where if the statement is true, it proceeds to create an infinite loop of "Enter a student mark [0.00, 100,00] : " and "No input accepted!".
#include <stdio.h>
#define MIN 0
#define MAX 100
int getMark(void) {
    int mark;
    char ch;
    int repeat = 1;
    printf("Enter a student mark [0, 100] :  ");
    int r = scanf("%i%c", &mark, &ch);
    if (r == 0) {
        printf("**No input accepted!**\n");           
    }
    else if (ch != '\n') {
         printf("**Trailing characters!**\n");
    }
    else if (mark < MIN || mark > MAX) {
        printf("**Out of range!**\n");
    }
    return mark;
}
int main() {
    int mark;
    do {
        mark = getMark();
    } while (mark != 0);
}
What's causing it to loop and how do I fix it?
 
     
     
    