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() { char a[4]="HELL"; printf("%s",a); }
What is the problem with the following code segment? while ((fgets(receiving array,50,file_ptr)) != EOF) ;
In a gymnastic competition, scoring is based on the average of all scores given by the judges excluding the maximum and minimum scores. Let the user input the number of judges, after that, input the scores from the judges. Output the average score. Note: In case, more than two judges give the same score and it happens that score is the maximum or minimum then just eliminate two scores. For example, if the number of judges is 5 and all of them give 10 points each. Then the maximum and minimum score is 10. So the computation would be 10+10+10, this time. The output should be 10 because 30/3 is 10.
What is the match merge ? compare data step match merge with proc sql merge - how many types are there ? data step vs proc sql
what is the output of the below program & why ? #include<stdio.h> void main() { int a=10,b=20,c=30; printf("%d",scanf("%d%d%d",&a,&b,&c)); }
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!
main() { char not; not=!2; printf("%d",not); }
How can I Create a C program in splitting set of characters to specific subsets. Example: INPUT SET OF CHARACTERS: Therefore, my dear brothers and sisters, stand firm. Let nothing move you. Always give yourselves fully to the work of the Lord, because you know that your labor in the Lord is not in vain. SPLIT INTO HOW MANY CHARACTERS PER SUBSETS: 10 OUTPUT: Therefore, my dear b rothers an d sisters, stand fir m. Let not hing move you. Alway s give you rselves fu lly to the work of t he Lord, b ecause you know that your labo r in the L ord is not in vain.
What is your nationality?
main() { int i=_l_abc(10); printf("%d\n",--i); } int _l_abc(int i) { return(i++); }
#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..?
main() { int i=5; printf("%d%d%d%d%d%d",i++,i--,++i,--i,i); }