FOR INPUT aabcc I WANT OUTPUT AS 2
BUT THE ANSWER IS 0
#include<stdio.h>
int main()
{ int n,k,counta=0,x;
scanf("%d",&n);
char a[n];
scanf("%s",a);
for(k=0;k<n;k++)
{
if(a[k]!=‘a’||a[k]!=‘e’||a[k]!=‘i’||a[k]!=‘o’||a[k]!=‘u’)
{x=k;
break;}
}
printf("%d\t",x);
}
Please format your code - the forum software has mangled it and it won’t compile!
Your test input:
aabcc
does not contain the number, n
, expected by your program.
no i want to find the place of first consonant that appears in the string
i want to find the place of first consonant that appear in the code
Well, that won’t work: the first letter, a
, satisfies:
(a[k]!='a'||a[k]!='e'||a[k]!='i'||a[k]!='o'||a[k]!='u'
(in particular, it satisfies a[k] != 'e'
).
Do you actually understand what the hell this code is doing or did you copy it from somewhere? The latter is more plausible considering these replies.
Actually, i am solving a problem this is just a part of that problem where i have to find the location in char array where the consonant appear for first time.
Actually, i am solving a problem this is just a part of that problem where i have to find the location in char array where the consonant appear for first time.