Help with a basic program

I have to convert some psuedocode into a C program.
Its a program which asks for an input from the keyboard, and prints whether it is a vowel or a consonant.

So far I have this:

1
2
3
4
5
6
7
8
9
10
#include <stdio.h>

    main()
    {
        int  letter;
        
        printf("Enter a lower case letter\n");
        scanf("%c", &letter);
        
    }


I want know how to re-ask for the input if there is no input, and then when it is inputed then how to determine if it was a vowel or consonant.
If there is no input, the program will wait forever at
scanf("%c", &letter);

If the user just pressed enter, the input will have a numerical value of 10 (new line).

So how about something like:

1
2
3
4
5
6
int  letter = 10;
while (letter == 10)
{
   printf("Enter a lower case letter\n");
   scanf("%c", &letter);
}

Last edited on
I couldn't seem to get that to work, when it did, it just spammed "Enter a lower case letter"
Best find out what your system does, then, so you can adapt it.

1
2
3
4
5
6
7
8
9
10
11
#include <stdio.h>

    main()
    {
        int  letter;
        
        printf("Enter a lower case letter\n");
        scanf("%c", &letter);
         printf("Numerical value of input was: %i", letter);
        
    }
That runs fine, but after I enter a key, it close the program so I can't see what it says
It just keeps on telling me that 'sleep' can't be used as a fuction, or 'system' can't be used as a function
Well then don't use sleep and don't use system.

Even better, go back a step and learn about header files and function declaration.
I would like to learn about how to code this properly, but this work is due in like a day...
Left it a bit late have we?

Lot's of learning to do in the next 24hrs then. Maybe you need to pull an all nighter.

Read this:

http://zanasi.chem.unisa.it/download/C.pdf


It's written by the guys who invented C. It's pretty old, but does teach the basics very well IMO.
Topic archived. No new replies allowed.