Home / Programs / Accept a character from the user and find it is a vowel or not without using any loop
🚀 Programming Example

Accept a character from the user and find it is a vowel or not without using any loop

👁 1,226 Views
💻 Practical Program
📘 Step Learning
Accept a character from the user and find it is a vowel or not without using any loop

💻 Program Code

// Accept a character from the user and find it is a vowel or not without using any loop
#include <stdio.h>
int main()
{
    char c;
    int isLVowel, isUVowel;

    printf("Enter an alphabet: ");
    scanf("%c",&c);

    
    isLVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

    
    isUVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

    
    if (isLVowel || isUVowel)
        printf("%c is a vowel.", c);
    else
        printf("%c is a consonant.", c);
    return 0;
}
                        

🖥 Program Output

Enter an alphabet: e
e is a vowel.
Press any key to continue . . .
                            

📘 Explanation

This program uses the concept of if statement
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.