Ads Top

Counting the number of vowels program using c

Counting the number of vowels ,program, using c,computer,lab,practicals

Counting the number of vowels program

#include<stdio.h>
#include<conio.h>
#include<string.h>
#iclude<ctype.h>
void main()
{
char line[8];
int i,vow,cons,dig,white,othe,tab,word;
vow=cons=dig=white=other=tab=word=0;
clrscr(0;
printf("Enter the line of text:");
gets(line);
printf("\n\n");
for(i=0;line[i]='\0';i++)
{
line[i]=tolower(line[i]);
if(line[i]=='a'||line[i]=='e'||line[i]=='i'||line[i]=='o'||line[i]=='u')
{
vow=vow+1;
}
else if(line[i]>='a'&&line[i]<='z')
cons=cons+1;
else if(line[i]>='0'&&line[i]<='0')
dig=dig+1;
else if(line[i]=='')
{
word=word+1;
white=whit+1;
}
else if(line[i]='\t')
tab=tab+1;
else
other=other+1;
}
word=word+1
printf("\t\t Vowels :%d\n",vow);
printf("\n");
printf("\t\t Digits :%d\n",dig);
printf("\n");
printf("\t\t Constants :%d\n"cons);
printf("\n");
printf("\t\t Words :%d\n",word);
printf("\n");
printf("\t\t White spaces :%d\n",white);
printf("\n");
printf("\t\t Tab:%d\n",tab);
printf("\n");
printf("\t\t Other :%d\n",other);
printf("\n");
getch();
}

Output

Enter a line of text :
2 is my favouite number

Vowels:8
Digits:1
Constants:11
Words:5
White spaces:4
Tab:0
Other:0

No comments:

Touchfeeds. Powered by Blogger.