mardi 7 avril 2020

Do not want to print multiple statement

I don't want my code to print other statements when the statement "is not a letter of the alphabet" is printed. Please help! I am still a noobie.

#include <stdio.h>

int main()
{
    char ch;
    int int_ch;

    do {

        printf("Type in an alphabet letter:");
        scanf("%c%*c", &ch);

        int_ch = (int)ch;
        printf("Ch has ascii value %d\n", ch);

        if ((ch >= 'a') && (ch <= 'z'))
        {
            int_ch = int_ch - 32;
        }
        else if ((ch >= 'A') && (ch <= 'Z'))
        {
            int_ch = int_ch + 32;
        }
        else
        {
            printf("Is not a letter of the Alphabet.");
        }

        //THIS HERE

        ch = (char)int_ch;

        printf("Ch is now %c\n", ch);
        printf("Ch is now ascii value %d\n", int_ch);

    } while (ch != '#');

    return (0);
}

Aucun commentaire:

Enregistrer un commentaire