Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* CABEÇALHO
- Arquivo: LISTA 05 - Exercicio 4.c
- Objetivo: Exibir quantidade de consoantes e vogais de algumas palavras.
- Autor(a): Ramon Borges
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- char nomes [][30] = {"Jose de Oliveira", "Joao Silverio", "Joana da Silva", "Mario da Silva Oliveira", "Pedro Oliveira de Souza"};
- int i, j, contvogal = 0, contchar = 0, totalvog = 0, totalchar = 0;
- for(i = 0; i < 5; i++)
- {
- for(j = 0; j < 30; j++)
- {
- if(nomes[i][j] == '\0')
- break;
- else if(nomes[i][j] >= 'a' && nomes[i][j] <= 'z') //Converte para maiuscula!!!
- nomes[i][j] -= 32;
- if(nomes[i][j]=='A' || nomes[i][j]=='E' || nomes[i][j]=='I' || nomes[i][j]=='O' || nomes[i][j]=='U')
- {
- contvogal++;
- contchar++;
- }
- else
- contchar++;
- }
- printf("\n%s - Vogais: %d, caracteres: %d", nomes[i], contvogal, contchar);
- totalvog += contvogal;
- totalchar += contchar;
- contvogal = contchar = 0;
- }
- printf("\nTOTAL DE VOGAIS: %d\nTOTAL DE CARACTERES: %d\n", totalvog, totalchar);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment