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
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 |
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 |
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 |
main() { int i = 258; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
main() { unsigned int i=10; while(i-->=0) printf("%u ",i); }
write a c program to Create employee record by taking details like name, employee id, address and phone number. While taking the phone number, take either landline or mobile number. Ensure that the phone numbers of the employee are unique. Also display all the details
main() { unsigned int i=65000; while(i++!=0); printf("%d",i); }
main() { void swap(); int x=10,y=8; swap(&x,&y); printf("x=%d y=%d",x,y); } void swap(int *a, int *b) { *a ^= *b, *b ^= *a, *a ^= *b; }
main() { extern i; printf("%d\n",i); { int i=20; printf("%d\n",i); } }
#include<stdio.h> main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; }
Link list in reverse order.
Write a program that find and print how many odd numbers in a binary tree
main() { int i=5,j=10; i=i&=j&&10; printf("%d %d",i,j); }
main() { int i=4,j=7; j = j || i++ && printf("YOU CAN"); printf("%d %d", i, j); }
main() { char not; not=!2; printf("%d",not); }