ramontricolor12

LISTA 05 - Exercício 04

Jul 8th, 2013
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.22 KB | None | 0 0
  1. /* CABEÇALHO
  2.    Arquivo: LISTA 05 - Exercicio 4.c
  3.    Objetivo: Exibir quantidade de consoantes e vogais de algumas palavras.
  4.    Autor(a): Ramon Borges
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. int main()
  10. {
  11.     char nomes [][30] = {"Jose de Oliveira", "Joao Silverio", "Joana da Silva", "Mario da Silva Oliveira", "Pedro Oliveira de Souza"};
  12.     int i, j, contvogal = 0, contchar = 0, totalvog = 0, totalchar = 0;
  13.  
  14.     for(i = 0; i < 5; i++)
  15.     {
  16.         for(j = 0; j < 30; j++)
  17.         {
  18.             if(nomes[i][j] == '\0')
  19.                 break;
  20.             else if(nomes[i][j] >= 'a' && nomes[i][j] <= 'z') //Converte para maiuscula!!!
  21.                 nomes[i][j] -= 32;
  22.             if(nomes[i][j]=='A' || nomes[i][j]=='E' || nomes[i][j]=='I' || nomes[i][j]=='O' || nomes[i][j]=='U')
  23.             {
  24.                 contvogal++;
  25.                 contchar++;
  26.             }
  27.             else
  28.                 contchar++;
  29.         }
  30.         printf("\n%s - Vogais: %d, caracteres: %d", nomes[i], contvogal, contchar);
  31.         totalvog += contvogal;
  32.         totalchar += contchar;
  33.         contvogal = contchar = 0;
  34.     }
  35.     printf("\nTOTAL DE VOGAIS: %d\nTOTAL DE CARACTERES: %d\n", totalvog, totalchar);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment