samedi 7 mars 2020

Check whether a character is a Vowel or Consonant

I need to make Check whether a character is a Vowel or Consonant as function and it returns 1 if it's a vowel and returns 0 if it's consonant

That's what I've come up with

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

int vowel(char c) {
    int lowercase, uppercase;

    lowercase = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
    uppercase = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

    if (lowercase || uppercase)
        return 1;
    else
        return 0;
}

int main() {
    char c;

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

}

Input: a

Output: Process returned 0

Aucun commentaire:

Enregistrer un commentaire