ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Code-Snippets >> Programming-Code >> C-Code
 
 
 
Question
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.
 Question Submitted By :: Vadivel152
I also faced this Question!!     Rank Answer Posted By  
 
Answer
#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;
}
 
0
Vadivel_152
 
View All Answers
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com