to get a line of text and count the number of vowels in it

Answer Posted / swe

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char st[100];
int i,count=0;
clrscr();
printf("Enter line of text:");
gets(st);
for(i=0;st[i]!='\0';i++)
{
switch(st[i])
{
case 'a':count++;
break;
case 'A':count++;
break;
case 'e':count++;
break;
case 'E':count++;
break;
case 'i':count++;
break;
case 'I':count++;
break;
case 'o':count++;
break;
case 'O':count++;
break;
case 'u':count++;
break;
case 'U':count++;
break;
}
}
printf("\n Number of vowels:%d",count);
getch();
}

Is This Answer Correct ?    32 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is getch () for?

667


Why can’t constant values be used to define an array’s initial size?

824


What are dangling pointers in c?

629


Explain the use of bit fieild.

702


Write a program to implement queue.

654






What standard functions are available to manipulate strings?

552


If I have a char * variable pointing to the name of a function ..

641


Why string is used in c?

572


A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor

616


What is #include called?

561


Why is c not oop?

533


Describe static function with its usage?

602


What is structure in c explain with example?

623


What are the difference between a free-standing and a hosted environment?

733


How can I copy just a portion of a string?

808