Build c by GCC have a problem?

void BT3()
{
    int gt = 1;
    char n, i;
    printf("
-----------------------------------------------------");
    printf("
---------");
    do
    {
        printf("
n = ");
        scanf("%d", &n);
    }while(n < 0 || n > 7);
    for (i = 1; i <  n +1; i++)
    {
        gt *= i;
    }
    printf("
%d! = %d", n, gt);
}

result not correct…
gt = 0
Example: n = 3; result gt = 0 not correct.
Why?

scanf using %d is meant to read into an int variable, not a char one. I don’t know why you used char for n and i. If you were doing it out of a sense of trying to save space, it’s futile. The compiler probably generates less efficient code for the loop using char because int is the native integer size and best suited for int operations.