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 |
Declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
1) int i=5; j=i++ + i++ + i++; printf("%d",j);This code gives the answer 15.But if we replace the value of the j then anser is different?why? 2)int i=5; printf("%d",i++ + i++ + i++); this givs 18.
main() { char *p; int *q; long *r; p=q=r=0; p++; q++; r++; printf("%p...%p...%p",p,q,r); }
main(int argc, char **argv) { printf("enter the character"); getchar(); sum(argv[1],argv[2]); } sum(num1,num2) int num1,num2; { return num1+num2; }
Which version do you prefer of the following two, 1) printf(“%s”,str); // or the more curt one 2) printf(str);
String copy logic in one line.
Write a C program to print look and say sequence? For example if u get the input as 1 then the sequence is 11 21 1211 111221 312211 12112221 .......(it counts the no. of 1s,2s etc which is in successive order) and this sequence is used in run-length encoding.
why the range of an unsigned integer is double almost than the signed integer.
#define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }
4 Answers Google, HCL, Quick Heal, WTF,
Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.
main( ) { void *vp; char ch = ‘g’, *cp = “goofy”; int j = 20; vp = &ch; printf(“%c”, *(char *)vp); vp = &j; printf(“%d”,*(int *)vp); vp = cp; printf(“%s”,(char *)vp + 3); }
What is the subtle error in the following code segment? void fun(int n, int arr[]) { int *p=0; int i=0; while(i++<n) p = &arr[i]; *p = 0; }