2
I am developing two functions in C language, the first to check whether a letter is a vowel or a consonant, without using any ready function. The first is working.
The second function checks whether the letter is uppercase or lowercase, but does not work for all letters. For example, the letter "a" does not show output.
#include <stdio.h>
#include <string.h>
char letras[52] = {'A','E', 'I','O','U',
'a','e', 'i','o','u',
'B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z',
'b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z'
};
void minusculaMaiuscula(char letra){
for (int i = 0; i < 52; i++){
if( (i < 5 | (i > 10 & i < 31)) & (letra == letras[i]) ){
printf("Maiuscula");
break;
}
else if ( (i > 5 & i < 31) & letra == letras[i] ){
printf("Minuscula");
break;
}
}
}
void vogalConsoante(char letra){
for (int i = 0; i < 52; i++){
if(i < 10 & letra == letras[i] ){
printf("Vogal");
break;
}
else if (i > 5 & letra == letras[i] ){
printf("Consoante");
break;
}
}
}
int main()
{
char letra = 'a';
minusculaMaiuscula(letra);
return 0;
}
Where is the error in my function minusculaMaiuscula(char letra)
and, how to improve these functions so that the code is more understandable and with less instructions?