[ create a new paste ] login | about

Link: http://codepad.org/luniSRSv    [ raw code | output | fork ]

vicenaf - C, pasted on Aug 17:
#include <stdio.h>
#include <stdlib.h>

int main()
{/*Contar las vocales de un texto*/
    char texto_teclado [100];
    int i, contador_letras [5]= {0,0,0,0,0};

    strcpy (texto_teclado, "En un lugar de la Mancha de cuyo nombre no quiero acordarme.");

    printf ("Escribe un texto de ata 100 caracteres e direiche cantas vogais escribiche: ");
    gets (texto_teclado);

    for (i=0; i < strlen(texto_teclado);i++)
    {
        switch (texto_teclado[i])
        {
            case 'A':
            case 'a':
                contador_letras[0]++;
                break;
            case 'E':
            case 'e':
                contador_letras[1]++;
                break;
            case 'I':
            case 'i':
                contador_letras[2]++;
                break;
            case 'O':
            case 'o':
                contador_letras[3]++;
                break;
            case 'U':
            case 'u':
                contador_letras[4]++;
                break;
        }
    }
    printf("\nExcribiches %d letras a.", contador_letras[0]);
    printf("\nExcribiches %d letras e.", contador_letras[1]);
    printf("\nExcribiches %d letras i.", contador_letras[2]);
    printf("\nExcribiches %d letras o.", contador_letras[3]);
    printf("\nExcribiches %d letras u.", contador_letras[4]);
    printf("\nExcribiches en total %d vocais.", contador_letras[0]+contador_letras[1]+contador_letras[2]+contador_letras[3]+contador_letras[4]);
    return 0;
}


Output:
1
2
3
4
5
6
7
Escribe un texto de ata 100 caracteres e direiche cantas vogais escribiche: 
Excribiches 6 letras a.
Excribiches 6 letras e.
Excribiches 1 letras i.
Excribiches 5 letras o.
Excribiches 4 letras u.
Excribiches en total 22 vocais.


Create a new paste based on this one


Comments: