dimanche 18 février 2018

Second cycle of main

I'm beginner in C and I just learning it, so please, don't be rude on me :)) I would like to ask about my code, what can be possibly wrong:

int main()
{
    char a;
    int b;
    printf("Please, tap your symbol: ");
    scanf("%c",&a);
    b = (char)a;
    if ((b>=97)&&(b<=122))
        printf("Symbol %c is small letter.\n\n",a);
    else if ((b>=65)&&(b<=96))
        printf("Symbol %c is big letter.\n\n",a);
    else if ((b>=48)&&(b<=57))
        printf("Symbol %c is number.\n\n",a);
    else if (b==63)
        printf("Symbol %c is question mark.\n\n",a);
    else if (b==33)
        printf("Symbol %c is exclamation mark.\n\n",a);
    else if (b==42)
        printf("Symbol %c is multiplication.\n\n",a);
    else if (b==64)
        printf("Symbol %c is at sing.\n\n",a);
    else if (b==35)
        printf("Symbol %c je sharp.\n\n",a);
    else if (b==94)
        printf("Symbol %c is XOR.\n\n",a);
    else
        printf("You tapped wrong symbol.\n\n");
    getch();
return main();
}

This program should recognize symbol and describe it. And heres a question: First cycle is running properly, but when main() is recalled in the end of the first cycle. Can be scanf function in 6th line is wrong? It's like in the second cycle was char a doesn't loaded. Thank you very much.

Aucun commentaire:

Enregistrer un commentaire