본문 바로가기
C and C++/C and C++ Examples

[C Examples] 알파벳 모음, 자음 구분하기 예제코드: switch()

by Henry Cho 2023. 3. 24.
728x90

알파벳 모음, 자음 구분하기 예제코드: switch()

포스트 난이도: HOO_Junior


# Example Codes

 

#include <stdio.h>
#include <stdlib.h>

    int main()
{
    char ch;
    printf("Enter any alphabet:"); //input alphabet from user
    scanf("%c", &ch);

    switch(ch){

    case 'A': printf("Vowel\n");
        break;
    case 'E': printf("Vowel\n");
        break;
    case 'I': printf("Vowel\n");
        break;
    case 'U': printf("Vowel\n");
        break;
    case 'O': printf("Vowel\n");
        break;
    case 'a': printf("Vowel\n");
        break;
    case 'e': printf("Vowel\n");
        break;
    case 'i': printf("Vowel\n");
        break;
    case 'u': printf("Vowel\n");
        break;
    case 'o': printf("Vowel\n");
        break;
    default: printf("Consonant\n");
        break;}
        
return 0;
}

# Results

 

Enter any alphabet:e
Vowel

 

Enter any alphabet:y
Consonant

 

728x90

댓글