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's the difference between a linked list and an array?

14 Answers  


how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software

0 Answers  


find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }

0 Answers   Microsoft,


Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;

2 Answers   Bosch,


Explain the Difference between the New and Malloc keyword.

0 Answers   InterGraph,






What is the function of multilevel pointer in c?

0 Answers  


How can I read a binary data file properly?

0 Answers  


Sir,please help me out with the output of this programme:- #include<stdio.h> #include<conio.h> void main() { int a=18,b=12,i; for(i=a<b?a:b;a%i||b%i;i--); printf("%d %d",i); }

4 Answers  


increment operateor (++)and decrament(--) #include<stdio.h> #inclide<conio.h> main() { int x=15; while(x!=0) scanf("%d",&x); {

2 Answers   HCL, Syntel, TCS,


What is the output of following program ? int main() { int x = 5; printf("%d %d %d\n", x, x << 2, x >> 2); }

5 Answers   Amazon, Qualcomm,


i want to know aptitude questions,technical questions

2 Answers  


What is define c?

0 Answers  


Categories