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                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories >> Code-Snippets >> Programming-Code >> C-Code
 
 
 
Question
Write a prog to accept a given string in any order and flash
error if any of the character is different. 

For example : If abc is the input then abc, bca, cba, cab
bac are acceptable, but aac or bcd are unacceptable.
 Question Submitted By :: Coder_1
I also faced this Question!!     Rank Answer Posted By  
 
Answer
if we ask the user to enter the second string having the 
same characters as in the first string, the program 
essentailly reduces to finding whether there is a 
repetition in the second string. A program for this is 
given below.

#include<iostream>
using namespace std;

int main()
{
	char string1[10];
	char string2[10];
	int flag = 0;

	cout<<"\n Enter the first string";
	cin>>string1;
	cout<<"\n Enter the second string with the same 
characters as entered in string1";
	cin>>string2;
	for(int i = 0; i < strlen(string2); i++)
	{
		for(int j = i+1; j < strlen(string2) ; j++)
		{
			if(string2[i] == string2[j])
			{
				flag = 1;
				break;
			}
		}
	}

	if(flag ==1)
		cout<<"\n wrong";
	else
		cout<<"\n correct";

	return 0;
}
 
0
Sivan
 
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