Sunday, May 5, 2013

Program to Count the number of vowels and consonants in a given string using Conditional operator


#include<stdio.h>
#include<string.h>
main()
{
    char s[25];
    int i,v=0,c=0;
    printf("Enter string--");   
    scanf("%s",&s);
    for(i=0;s[i]!='\0';i++)
    (s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='i'||s[i]=='o'||s[i]=='u')?v++:c++;
    printf("the count of v is %d \n the count of c is %d",v,c);
    getch();
}

output
Enter string--
this
the count of v is 1
 the count of c is 3

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More