plz can u help me with this program
this is the question & the answer too...............
Write a C program that reads several lines of text and then using menu-based interface write the following:
1- A function count_Alphabet_Words : this function will find how many words in the input text begins with an alphabet
2- A function count_Vowels : this function will find how many vowel letters are in the input text. (vowels are: a, i, e, u, o)
3- A function Search_word that will asks for a word and then find how many times this word is reapeated in the input text
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int countalphawords(char string[100])
{
char *p;
int count=0;
p=strtok(string," ");
while (p!=NULL)
{
if (isdigit(*p)==0)
count++;
p=strtok(NULL," ");
}
return (count);
}
int countvowels(char string[100])
{
char *p,*q;
int count=0;
p=strtok(string," ");
while (p!=NULL)
{
q=p;
while (*q!='\0')
{
switch (*q)
{
case 'a': count++;
break;
case 'e': count++;
break;
case 'i': count++;
break;
case 'o': count++;
break;
case 'u': count++;
break;
case 'A': count++;
break;
case 'E': count++;
break;
case 'I': count++;
break;
case 'O': count++;
break;
case 'U': count++;
break;
}
q++;
}
p=strtok(NULL," ");
}
return (count);
}
int countsearchword(char string[100],char word[20])
{
char *p;
int count=0;
p=strtok(string," ");
while (p!=NULL)
{
if (strcmp(p,word)==0)
count++;
p=strtok(NULL," ");
}
return (count);
}
int main ()
{
char string[100],key[20],string1[100],string2[100];
int lines;
int count=0,count1=0,count2=0;
int count3=0,count4=0,count5=0;
printf("Enter # of lines you want to output:\n");
scanf("%d",&lines);
printf("Enter the word you want to look for in the text:\n");
scanf("%s",&key);
gets(string);
for(int i=1;i<=lines;i++)
{
gets(string);
strcpy(string1,string);
strcpy(string2,string);
count1= countvowels(string);
count2= countsearchword(string1,key);
count= countalphawords(string2);
printf("\nIn line %d there are %d alpha words,%d searchwords,%d vowels\n",i,count,count1,count2);
count3+=count;
count5+=count2;
count4+=count1;
}
printf(" \n In the hole text %d alpha words,%d searchwords,%d vowels\n",count3,count4,count5);
return 0;
}