Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
791 B
1
Indexable
Never
#include <stdio.h>
#include <string.h>

int isVowel(char c) {
    switch(c) {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
            return 1;
        default:
            return 0;
    }
}

int main() {
    char input[100], output[100];
    int i, j = 0;
    
    printf("Enter a string: ");
    fgets(input, sizeof(input), stdin);
    input[strcspn(input, "\n")] = '\0'; // remove newline character
    
    for(i = 0; input[i] != '\0'; i++) {
        if(isVowel(input[i])) {
            output[j++] = input[i];
        }
    }
    output[j] = '\0';
    
    printf("Result: %s\n", output);
    
    return 0;
}