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   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
Concat two string with most overlapped substring has to 
remove  "abcd"+ "cdef" = "abcdef
 Question Submitted By :: San
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef
Answer
# 1
#include<stdio.h>
main()
{
char *a="abcd";
char *b="cdef";
char c[10];
int i=0;
while(*a != *b)
{
c[i] = *a++;
i++;
}
while(*b != '\0')
{
c[i]= *b++;
i++;
}
printf("%s\n",c);
}
 
Is This Answer Correct ?    1 Yes 2 No
Tarak
 
  Re: Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef
Answer
# 2
above code some thing wrong.
if "abcd","cefg" then output will be "abcdcefg"
but above code will give "abcefg"
 
Is This Answer Correct ?    1 Yes 0 No
Durga Prasad
 
 
 
  Re: Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef
Answer
# 3
Check the each char in the second string with first string
if it is not there then concatenate into the first string else
do not do.
 
Is This Answer Correct ?    0 Yes 0 No
Sham
 
  Re: Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef
Answer
# 4
char *strappend1(char *src,char *des)
{
 char *tmp=src;
 int f=0;
 while(*des)
 {
   while(*src!='\0')
   {
    if(*src==*des)
    {
     f=0;
     break;
    }
    else
      f=1;
    src++;
   }
  if(f==1)
  {
   *src++=*des;
   *src='\0';
  }
  des++;
 }
 return tmp;
}
int main(int argc,char **argv)
{
 char *src=argv[1],*des=argv[2];
 char *str;
 str=strappend1(src,des);
 printf("%s",str);
}
 
Is This Answer Correct ?    0 Yes 0 No
Sham
 
  Re: Concat two string with most overlapped substring has to remove  "abcd"+ "cdef" = "abcdef
Answer
# 5
the code given by tarak is correct 

ie

#include<stdio.h>
main()
{
char *a="abcd";
char *b="cdef";
char c[10];
int i=0;
while(*a != *b)
{
c[i] = *a++;
i++;
}
while(*b != '\0')
{
c[i]= *b++;
i++;
}
printf("%s\n",c);
}

  

but the answer is abcdef and some garbage values yar 

abcdef{}>>>M<C<P{{  

to get perfect answer just add '\o' at end of the code and
before printf dear 




#include<stdio.h>
main()
{
char *a="abcd";
char *b="cdef";
char c[10];
int i=0;
while(*a != *b)
{
c[i] = *a++;
i++;
}
while(*b != '\0')
{
c[i]= *b++;
i++;
}

c[i]='\0';  //// new added line here






printf("%s\n",c);
}
 
Is This Answer Correct ?    0 Yes 0 No
Ashwin Kumar
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } CitiGroup15
Binary tree traversing Qualcomm1
What character terminates all strings composed of character arrays? 1) 0 2) . 3) END  3
Look at the Code: main() { int a[]={1,2,3},i; for(i=0;i<3;i++) { printf("%d",*a); a++; } } Which Statement is/are True w.r.t the above code? I.Executes Successfully & Prints the contents of the array II.Gives the Error:Lvalue Required III.The address of the array should not be changed IV.None of the Above. A)Only I B)Only II C)II & III D)IV Accenture3
9.how do you write a function that takes a variable number of arguments? What is the prototype of printf () function? 10.How do you access command-line arguments? 11.what does ‘#include<stdio.h>’ mean? 12.what is the difference between #include<> and #include”…”? 13.what are # pragma staments? 14.what is the most appropriate way to write a multi-statement macro?  1
How can I allocate arrays or structures bigger than 64K?  4
HOW TO SWAP TWO NOS IN ONE STEP? Satyam12
int i; i=2; i++; if(i=4) { printf(i=4); } else { printf(i=3); } output of the program ? Mascot9
how does the C compiler interpret the following two statements p=p+x; q=q+y; a.p=p+x; q=q+y b.p=p+xq=q+y c.p=p+xq; q=q+y d.p=p+x/q=q+y TCS3
Main must be written as a.the first function in the program b.Second function in the program c.Last function in the program d.any where in the program TCS12
how many times of error occur in C  7
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes HCL11
how to find out the reverse number of a digit if it is input through the keyboard?  2
design and implement a program that reads floating-points numbers in a sentinel-controlled loop until the user terminates the program by entering zero.your program should determinate and print the smallest,largest and average of the supplied numbers.  1
#include<stdio.h> int SumElement(int *,int); void main(void) { int x[10]; int i=10; for(;i;) { i--; *(x+i)=i; } printf("%d",SumElement(x,10)); } int SumElement(int array[],int size) { int i=0; float sum=0; for(;i<size;i++) sum+=array[i]; return sum; } output? Ramco5
can anyone proide me reading material on svit00ef27@yahoo.com please thanx in advance IBM1
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above Accenture4
52.write a “Hello World” program in “c” without using a semicolon? 53.Give a method to count the number of ones in a 32 bit number? 54.write a program that print itself even if the source file is deleted? 55.Given an unsigned integer, find if the number is power of 2?  5
1,4,8,13,21,30,36,45,54,63,73,?,?. Franklin-Templeton5
write a program structure to find average of given number  1
 
For more C 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