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); }
main() { signed int bit=512, i=5; for(;i;i--) { printf("%d\n", bit >> (i - (i -1))); } } a. 512, 256, 0, 0, 0 b. 256, 256, 0, 0, 0 c. 512, 512, 512, 512, 512 d. 256, 256, 256, 256, 256
why is printf("%d %d %d",i++,--i,i--);
how can i cast a char type array to an int type array
main() { int i = 257; int *iPtr = &i; printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) ); }
Is the following code legal? typedef struct a aType; struct a { int x; aType *b; };
abcdedcba abc cba ab ba a a
#include<stdio.h> main() { int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} }; int *p,*q; p=&a[2][2][2]; *q=***a; printf("%d----%d",*p,*q); }
prog. to produce 1 2 3 4 5 6 7 8 9 10
main() { int c[ ]={2.8,3.4,4,6.7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf(" %d ",*c); ++q; } for(j=0;j<5;j++){ printf(" %d ",*p); ++p; } }
#include"math.h" void main() { printf("Hi everybody"); } if <stdio.h> will be included then this program will must compile, but as we know that when we include a header file in "" then any system defined function find its defination from all the directrives. So is this code of segment will compile? If no then why?
#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); }