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

Answers were Sorted based on User's Feedback



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

Answer / anil kumar nahak

void main()
{
char *st;
int i=0,c=0;
printf("\n Enter A String:");
gets(st);
while(st[i]!='\0')
{
if(st[i]=='a' || st[i]=='A' || st[i]=='e' || st[i]=='E'
st[i]=='i' || st[i]=='I' || st[i]=='o' st[i]=='O' st[i]=='u'
|| st[i]=='U')
c++;
i++;
}

printf("\n the Number Of Vowels Present In The String Is :
%d",c);

}

Is This Answer Correct ?    3 Yes 1 No

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

Answer / vadivel t

#include<stdio.h>
#include<conio.h>

int main()
{
char ptr[100]= "She lives in NEWYORK";
printf("VOWELS EXIST %d TIME(S)\n",CountVow(ptr));
getch();
}

int CountVow(char *ptr)
{
int count = 0;
while(*ptr != '\0')
{
if((*ptr == 'a') || (*ptr == 'A') || (*ptr == 'e') ||
(*ptr == 'E') || (*ptr == 'i') ||
(*ptr == 'I') || (*ptr == 'o') || (*ptr == 'O') ||
(*ptr == 'u') || (*ptr == 'U'))
{
count++;
}
ptr++;
}
return count;
}

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More C Interview Questions

What does sizeof int return?

0 Answers  


What are header files? What are their uses?

0 Answers  


What is modifier & how many types of modifiers available in c?

0 Answers  


what does data structure mean?

8 Answers  


What is the translation phases used in c language?

0 Answers  






What is a shell structure examples?

0 Answers  


What is the purpose of void pointer?

0 Answers  


How many types of errors are there in c language? Explain

0 Answers  


Is c is a procedural language?

0 Answers  


WAP that prints the number from 1 to 100. but for multiplies of three print "XXX" instead of the number and for the multiplies of five print "YYY" . for number which are multiplies of both three and five print "ZZZ"

3 Answers  


program to find the magic square

1 Answers   Infosys,


a simple program in c language

5 Answers   IBM,


Categories