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 is structure in c language?

0 Answers  


write an interactive program to generate the divisors of a given integer.

7 Answers   TCS,


What is the use of typedef in c?

0 Answers  


why programming language C is still used in operating system's kernel??

1 Answers   Wipro,


Which function in C can be used to append a string to another string?

0 Answers  






what is self refrential structure

3 Answers   HCL,


How will you declare an array of three function pointers where each function receives two ints and returns a float?

0 Answers   TISL,


What is pass by reference in c?

0 Answers  


What is difference between structure and union in c?

0 Answers  


Differentiate between a for loop and a while loop? What are it uses?

0 Answers   TISL,


What are register variables in c?

0 Answers  


How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;

2 Answers  


Categories