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
 
 


 

 
 C Code interview questions  C Code Interview Questions
 C++ Code interview questions  C++ Code Interview Questions
 VC++ Code interview questions  VC++ Code Interview Questions
 Java Code interview questions  Java Code Interview Questions
 Dot Net Code interview questions  Dot Net Code Interview Questions
 Visual Basic Code interview questions  Visual Basic Code Interview Questions
 Programming Code AllOther interview questions  Programming Code AllOther Interview Questions
Question
write the function. if all the character in string B appear in
string A, return true, otherwise return false.
 Question Submitted By :: PK
I also faced this Question!!     Rank Answer Posted By  
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 1
#include<iostream.h>
#include<stdio.h>
#include<string.h>
int main()
{
char str1[100],str2[100];
int flag1=0,flag=0;
cout<<"\n\nenter 1st string:";
cin>>str1;
cout<<"\n\nenter 2nd string:";
cin>>str2;
int i=0,j=0;
for(i=0;i<strlen(str1);i++)
{ flag=0;
for(j=0;j<strlen(str2);j++)
{
if(str1[i]==str2[j])
{flag=1;
str2[j]=' ';
break;
}
}
if(flag==0)
{
flag1=1;
cout<<"\n\nnot anagrams";
break;
}
}
if(flag1!=1)
cout<<"\nanagrams";


return 0;

 }


 
Is This Answer Correct ?    0 Yes 0 No
Raghuram
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 2
#include<iostream.h>
#include<string.h>
int h(char letter)
{

return(letter-97);
}

int main()

{

char str1[100],str2[100];

int i=0,count[26];
for(i=0;i<26;i++)

count[i]=0;

clrscr();
cout<<"\n\nenter 1st string:";

cin>>str1;

cout<<"\n\nenter 2nd string:";

cin>>str2;
for(i=0;i<strlen(str1);i++)

{

count[h(str1[i])]++;

}
for(i=0;i<strlen(str2);i++)

{

count[h(str2[i])]--;
}      int flag=0;

for(i=0;i<26;i++)

{if(count[i]!=0)
{cout<<"\n\nnot anagrams";

flag=1;

break;

}
}

if(flag==0)

cout<<"\n\nanagrams";

return 0;

}
 
Is This Answer Correct ?    0 Yes 0 No
Raghuram.A
 
 
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 3
#include<iostream.h>
void main()
{
char a,b;
cout<<"Entr the values of a & b";
cin>>a>>b;
if(strcmp(a,b))
cout<<"Both a & b are the same";
else
cout<<"A & b are different";
}
 
Is This Answer Correct ?    1 Yes 0 No
Defcon
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 4
private bool IsPartOf(string B, string A)
        {
            if(A==null || B==null) return false;
            if(B.Length>A.Length) return false;
            A = A.ToLower();
            B = B.ToUpper();

            for(int i=0; i<A.Length;i++)
            {
                if((i<B.Length)&&(A[i]==B[i]))
                {
                    bool found = true;
                    for(int j=i;j<B.Length;j++)
                    {
                        if(A[j]!=B[j])
                        {
                            found = false;
                            break;
                        }
                    }
                    if(found) return true;
                }
            }
            return false;
        }
 
Is This Answer Correct ?    0 Yes 0 No
Sam
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 5
using namespace std;
#include<iostream>
#include<conio.h>
#include<string.h>

int main()
{
char str1[10],str2[10],temp[10];
char *p,*q;
int flag=1;

cout<<"enter the two strings"<<endl;
cin>>str1;
cout<<"and"<<endl;
cin>>str2;

p=str1;

//strcpy(str2,temp);
//cout<<temp;
if(strlen(str1)!=strlen(str2))
flag=0;

while(*p)
{
char ch=*p;
q=str2;
while(*q)
{
         if(ch!=*q)
         q++;
         else
         {
             *q='*';
              break;
         } 
}
if((*q)=='\0')
{flag=0;
 break;
}
p++;

}

if(flag)
cout<<"anagrams"<<endl;
else
cout<<"not anagrams"<<endl;

getch();
return 0;
}
 
Is This Answer Correct ?    0 Yes 0 No
Tushar
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 6
#include<stdio.h>
#include<string.h>

int main()
{
        char *str1 = "Hello";
        char *str2 = "Hello";

        int len1,len2;
        len1 = strlen(str1);
        len2 = strlen(str2);
        if(len1 != len2)
        {
                printf("\nBoth Strings are not matched");
                return 0;
        }

        while(*str1)
        {
                if(*str1 == *str2)
                {
                        *str1++;
                        *str2++;
                }
                else
                {
                        printf("\nString Not Matched\n");
                        return 0;
                }
        }
        printf("\nBoth String are EQual");
}
 
Is This Answer Correct ?    0 Yes 0 No
Kathiresan
 
  Re: write the function. if all the character in string B appear in string A, return true, otherwise return false.
Answer
# 7
why u all waisting time... First understand problem then solve. 
Problem is like that

suppose B  = "iwantto"
        A = "Hiwannachatoopsthatiswhy"

Now here all character of B is in A string...

Okay!!!
 
Is This Answer Correct ?    0 Yes 0 No
Latter
 

 
 
 
Other C Code Interview Questions
 
  Question Asked @ Answers
 
How will u find whether a linked list has a loop or not? Microsoft3
Give a one-line C expression to test whether a number is a power of 2. Microsoft7
Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it. Microsoft4
Write out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba. You can assume that all the characters will be unique. Microsoft3
write a program to Insert in a sorted list Microsoft4
how to return a multiple value from a function? Wipro1
How to reverse a String without using C functions ? Wipro8
print numbers till we want without using loops or condition statements like specifically(for,do while, while swiches, if etc)!  7
String reverse with time complexity of n/2 with out using temporary variable. NetApp7
write the function. if all the character in string B appear in string A, return true, otherwise return false. Google7
How we will connect multiple client ? (without using fork,thread) TelDNA2
to remove the repeated cahracter from the given caracter array. i.e.., if the input is SSAD output should of SAD Synergy6
Sorting entire link list using selection sort and insertion sort and calculating their time complexity NetApp1
Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9). Microsoft8
Finding a number which was log of base 2 NetApp1
Write a function to find the depth of a binary tree. Adobe4
programming in c lanugaue programm will errror error with two header file one as stdio.h and other one is conio.h  1
Find your day from your DOB? Microsoft11
write a program to count the number the same (letter/character foreg: 's') in a given sentence.  1
Write a program that find and print how many odd numbers in a binary tree  1
 
For more C Code Interview Questions Click Here 
 
 
 
 
 
   
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