HOME

Friday, April 10, 2015

COUNT VOWEL, CONSONANT, NUMBER, WHITE SPACE & LENGTH PRESENT IN GIVEN STRING USING C PROGRAM

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char string[100];
int v=0,c=0,w=0,nu=0,n,i;
printf("enter the string\n");
gets(string);
n=strlen(string);
for(i=0;i<n;i++)
{
    if(string[i]=='a'||string[i]=='A'||string[i]=='e'||string[i]=='E'||string[i]=='i'||string[i]=='I'||string[i]=='o'||string[i]=='O'||string[i]=='u'||string[i]=='U')
    {
        v++;
    }
    else if(string[i]>='a' && string[i]<='z' || string[i]>='A' && string[i]<='Z')
    {
        c++;
    }
    else if(string[i]==' ')
    {
        w++;
    }
    else if(string[i]>='0'&& string[i]<='9')
    {
        nu++;
    }
}
printf("total number of word letter present is %d\n",v);
printf("total number of consonant letter present is %d\n",c);
printf("total number of number present is %d\n",nu);
printf("total number of white space present is %d\n",w);
printf("total number of letter present is %d",n);
}

No comments:

Post a Comment