-
-
Save parzibyte/e1d67274fc59665af200ab516d63a58d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://parzibyte.me/blog | |
*/ | |
#include <stdio.h> | |
#include <ctype.h> | |
int esVocal(char letra) | |
{ | |
// Convertir para simplificar comparaciones | |
char letraMinuscula = tolower(letra); | |
char vocales[] = "aeiou"; | |
// Recorrer las vocales y comparar si la letra es una de ellas | |
int i; | |
for (i = 0; vocales[i]; i++) | |
{ | |
if (letraMinuscula == vocales[i]) | |
{ | |
return 1; | |
} | |
} | |
// Si terminamos de recorrer y no regresamos true dentro del for, entonces no es vocal | |
return 0; | |
} | |
int esConsonante(char letra) | |
{ | |
return isalpha(letra) && !esVocal(letra); | |
} | |
int main(int argc, char const *argv[]) | |
{ | |
char cadena[] = "Hola mundo. Programando en C desde Parzibyte. 1 + 1 = 2"; | |
int i; | |
for (i = 0; cadena[i] != '\0'; i++) | |
{ | |
char letraActual = cadena[i]; | |
printf("'%c' ", letraActual); | |
if (esVocal(letraActual)) | |
{ | |
printf("es vocal"); | |
} | |
else if (esConsonante(letraActual)) | |
{ | |
printf("es consonante"); | |
} | |
else | |
{ | |
printf("no es vocal ni consonante"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment