Advertisement
Jkljk

contar vogais

Jun 23rd, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. /*Escreva um programa que solicite ao usuário para digitar seu nome completo e
  2. armazene em uma string. Em seguida conte quantas vogais existem nessa string.*/
  3. #include <stdio.h>
  4. #include <string.h>
  5. #define tam 100
  6. #include <conio.h>
  7. int main(){
  8. int i=0,j;
  9. char nome[tam];
  10. printf("\ninforme o seu nome:\n");
  11. fgets(nome,tam,stdin);
  12. fflush(stdin);
  13. for(j=0;j<tam;j++){
  14. switch (nome[j]) {
  15.     case 'a' : i++;
  16.     break;
  17.     case 'e' : i++;
  18.     break;
  19.     case 'i' : i++;
  20.     break;
  21.     case 'o' : i++;
  22.     break;
  23.     case 'u' : i++;
  24.     break;
  25.     case 'A' : i++;
  26.     break;
  27.     case 'E' : i++;
  28.     break;
  29.     case 'I' : i++;
  30.     break;
  31.     case 'O' : i++;
  32.     break;
  33.     case 'U' : i++;
  34.     break;
  35. }
  36. }
  37. printf("\nquantidade de vogais: %d",i);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement