Advertisement
Advatre

L2APCQ4

Jun 25th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. //Questão 4
  4. /* Escreva um programa que solicite ao usuário para
  5. digitar seu nome completo e armazene em uma string.
  6. Em seguida conte quantas vogais existem nessa string.*/
  7. int vogal,i;
  8. char nome[300];
  9. int main(){
  10. printf("Digite seu nome completo: ");
  11. gets(nome);
  12. if (strlen(nome)>300){
  13.     printf("\nNome muito grande, tente novamente com um nome menor.");
  14.     return 0;
  15. }
  16. for (i=0;i<strlen(nome);i++){
  17.     if (tolower(nome[i])=='a')
  18.     vogal++;
  19.     if (tolower(nome[i])=='e')
  20.     vogal++;
  21.     if (tolower(nome[i])=='i')
  22.     vogal++;
  23.     if (tolower(nome[i])=='o')
  24.     vogal++;
  25.     if (tolower(nome[i])=='u')
  26.     vogal++;}
  27. printf("\nQuantidade de vogais no seu nome: %d",vogal);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement