1
Guys help me: the exercise I’m trying to do is 4. Write a program in which:
a) A character must be read that is one of the vowels of the alphabet and may be uppercase or lowercase.
b) a function is implemented in which to check which vowel has been read, print in the function itself one of the following messages, as the case may be:
1st vowel,
second vowel,
third vowel,
4th vowel,
5th vowel or
Another character
Can someone tell me what I’m doing wrong?
#include<stdlib.h>
#include<locale.h>
char VogaLida (char Vogal [], int TamanhoVetor);
int main (){
setlocale(LC_ALL, "PORTUGUESE");
char Vogal [] = {'a', 'e', 'i', 'o', 'u'};
char VogalLida;
printf("Informe uma vogal: ");
gets(Vogal);
VogalLida = VogaLida(Vogal, 5);
}
char VogaLida (char Vogal [], int TamanhoVetor)
{
int i = 0;
for (i = 0; i < 5; i++){
if (i == Vogal[0]) {
Vogal[0] = 'a' | 'A';
printf("1ª Vogal\n");
return 0;
}
else if (i == Vogal[1]){
Vogal[1] = 'e' | 'E';
printf("2ª Vogal\n");
return 0;
}
else if (i == Vogal[2]){
Vogal[2] = 'i' | 'I';
printf("3ª Vogal\n");
return 0;
}
else if (i == Vogal[3]){
Vogal[3] = 'o' | 'O';
printf("4ª Vogal\n");
return 0;
}
}
return 0;
}
If Christian’s answer solved your problem you can mark it as accepted. Otherwise you can give an answer of your own to explain the solution.
– Sergio