When two vowels come one after another then the count should increment.But i dont know why its incrementing it more than that.
#include<stdio.h>
#include<conio.h>
void main(void)
{
int i,j,count=0;
char string[80];
printf("Enter a string:\n");
gets(string);
for(i=0; ;i++)
{
if(string[i]=='\0')
break;
if(string[i]=='a'||string[i]=='A'||string[i]=='e'||string[i]=='E'||string[i]=='i'||string[i]=='I'||string[i]=='o'||string[i]=='O'||string[i]=='u'||string[i]=='U')
{
if(string[i+1]=='a'||string[i]=='A'||string[i]=='e'||string[i]=='E'||string[i]=='i'||string[i]=='I'||string[i]=='o'||string[i]=='O'||string[i]=='u'||string[i]=='U')
count++;
}
}
printf("%d",count);
getch();
}
For once, be as lazy as you can. If you have to repeat a portion of code, ask yourself if you can’t do it without repeating.
I would have gone for that :