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                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
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
#include<iostream.h>
#include<string.h>
int main()
{
        int flag=0,i=0,j=0;
        char ar[4]="abc" ;
        char temp[4];
        cout<<"Plz enter a string with size #3";
        cin>>temp;
for(j=0;ar[j];j++)
        {
                flag=0;
                for(i=0;temp[i];i++)
                {
                        if(ar[j]==temp[i])
                                flag+=1;
                }
                if(flag==0||flag>1)
                        break;
        }
        if(flag==0||flag>1)
                cout<<"Not accepted";
        else
		cout<<"Accepted";
}
Note:PLz convert "iostream.h" into "stdio.h" and "cout<<" 
to "printf"
 
0
Santhoo035
[Nan]
 
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