You are given any character string. Find the number of sets
of vowels that come in the order of aeiou in the given
string. For eg., let the given string be DIPLOMATIC. The
answer returned must be "The number of sets is 2" and "The
sets are "IO and AI". Vowels that form a singleton set must
be neglected. Try to post the program executable in gcc or
g++ or in java.

Answers were Sorted based on User's Feedback



You are given any character string. Find the number of sets of vowels that come in the order of aei..

Answer / vadivel_152

#include<stdio.h>
#include<string.h>

int vowelsubset();
void separate();

char vowel[] = {'a','e','i','o','u'};
char str[100],res[50];
int main()
{
scanf("%s",str);
separate();
printf("The No. of sets are: %d\n",vowelsubset());
return 0;
}
void separate()
{
int i,j,x=0;
for(i = 0;i<strlen(str);i++)
for(j = 0;j<5;j++)
if(str[i] == vowel[j])
res[x++] = str[i];
res[x] = ''\0;
}
int vowelsubset()
{
if( (strlen(res)==0 )|| (strlen(res)==1) )
return 0;
int cnt = 0,i,j,x,k,flag;
for(i = 0;i<strlen(res);i++)
{
for(j = 0;j<5;j++)
if( (res[i] == vowel[j]) && (vowel[j]!='u'))
{
flag = 0;
for(k = i+1;k<strlen(res);k++)
{
if(res[k]<=vowel[j])
{
i = k-1;
goto label;
}
for(x = j+1;x<5;x++)
if(res[k] == vowel[x])
flag = 1;

}
label:
if(flag == 1)
cnt++;
}
}
return cnt;
}

Is This Answer Correct ?    4 Yes 1 No

You are given any character string. Find the number of sets of vowels that come in the order of aei..

Answer / sumedha sk

str="DIPLOMATIC"
str=lcase(str)
strlen=len(str)

vowelcnt=0

For pos=1 to strlen
charofstr=mid(str,pos,1)
If (charofstr="a") or (charofstr="e") or
(charofstr="i") or
(charofstr="o") or (charofstr="u") Then
vowelcnt=vowelcnt+1
End If
Next

msgbox "no of vowels are:"& vowelcnt

Is This Answer Correct ?    3 Yes 1 No

You are given any character string. Find the number of sets of vowels that come in the order of aei..

Answer / rohini

str="DIPLOMATIC"
str=lcase(str)
strlen=len(str)

vowelcnt=0

For pos=1 to strlen
charofstr=mid(str,pos,1)
If (charofstr="a") or (charofstr="e") or (charofstr="i") or
(charofstr="o") or (charofstr="u") Then
vowelcnt=vowelcnt+1
End If
Next

msgbox "no of vowels are:"& vowelcnt

Is This Answer Correct ?    3 Yes 3 No

Post New Answer

More C Code Interview Questions

union u { union u { int i; int j; }a[10]; int b[10]; }u; main() { printf("\n%d", sizeof(u)); printf(" %d", sizeof(u.a)); // printf("%d", sizeof(u.a[4].i)); } a. 4, 4, 4 b. 40, 4, 4 c. 1, 100, 1 d. 40 400 4

3 Answers   HCL,


#include <stdio.h> #define a 10 main() { #define a 50 printf("%d",a); }

2 Answers  


write a c program to Create a registration form application by taking the details like username, address, phone number, email along with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 5 users and display the details. In place of password display “****”. (Use Structures).

0 Answers   CDAC, College School Exams Tests,


main() { int i=400,j=300; printf("%d..%d"); }

3 Answers  


what is oop?

3 Answers  






main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }

1 Answers  


#include<stdio.h> void fun(int); int main() { int a; a=3; fun(a); printf("\n"); return 0; } void fun(int i) { if(n>0) { fun(--n); printf("%d",n); fun(--n); } } the answer is 0 1 2 0..someone explain how the code is executed..?

1 Answers   Wipro,


Display the time of the system and display the right time of the other country

1 Answers  


How do you create a really large matrix (i.e. 3500x3500) in C without having the program crash? I can only reach up to 2500. It must have something to do with lack of memory. Please help!

1 Answers  


Write a program to check whether the number is prime and also check if it there i n fibonacci series, then return true otherwise return false

1 Answers   Cognizant, lenovo,


#include<stdio.h> main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }

1 Answers  


Give a very good method to count the number of ones in a 32 bit number. (caution: looping through testing each bit is not a solution)

7 Answers   Microsoft,


Categories