Saturday, May 21, 2011

Program C Menghitung Jumlah Konsonan pada Kata

#include <stdio.h>
#include <conio.h>

char kata[30];
int i, jumKonsonan;

int main ()
{
     printf("Masukkan kata: ");
     gets(kata);
    
     i=0;
     while (kata[i] != '\0')
     {
           if (( kata [i] != 'a') && ( kata [i] != 'i') && ( kata [i] != 'u') && ( kata [i] != 'e') && ( kata [i] != 'o') && ( kata [i] != ' '))
           jumKonsonan++;
           i++;
           }
     printf("Jumlah konsonan: %d", jumKonsonan);
     printf("\n\n====================================================\n");
     printf("\t\tVera Suryaningsih\n\tCopyright spirit221.blogspot.com\n");
     printf("\n====================================================\n");         
     getch();
     return 0;
}

Output

0 comments:

Post a Comment