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  >>  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
what will the following program do?
                     void main()
                     {
                             int i;
                             char a[]="String";
                             char *p="New Sring";
                             char *Temp;
                             Temp=a;
                             a=malloc(strlen(p) + 1);
                             strcpy(a,p);                  
 //Line no:9//
                             p = malloc(strlen(Temp) + 1);
                             strcpy(p,Temp);
                             printf("(%s, %s)",a,p);
                             free(p);
                             free(a);
                     }                                     
 //Line no 15//

  a) Swap contents of p & a and print:(New string, string)
  b) Generate compilation error in line number 8
  c) Generate compilation error in line number 5
  d) Generate compilation error in line number 7
  e) Generate compilation error in line number 1
 Question Submitted By :: Guest
I also faced this Question!!     Rank Answer Posted By  
 
  Re: what will the following program do? void main() { int i; char a[]="String"; char *p="New Sring"; char *Temp; Temp=a; a=malloc(strlen(p) + 1); strcpy(a,p); //Line no:9// p = malloc(strlen(Temp) + 1); strcpy(p,Temp); printf("(%s, %s)",a,p); free(p); free(a); } //Line no 15// a) Swap contents of p & a and print:(New string, string) b) Generate compilation error in line number 8 c) Generate compilation error in line number 5 d) Generate compilation error in line number 7 e) Generate compilation error in line number 1
Answer
# 1
a = malloc....


this sentence will give the error Lvalue required..
 
Is This Answer Correct ?    1 Yes 0 No
Abhiraj
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
writw a program to insert an element in the begning of a doubly linked list  1
Given a single Linked list with lakhs of nodes and length unknown how do you optimally delete the nth element from the list? Oracle1
Give a fast way to multiply a number by 7 Microsoft8
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.  2
size maximum allocated by calloc() DELL1
how we can make 3d venturing graphics on outer interface Microsoft1
any string of bits of length 'n' represents a unique non- negative integer between.............?  2
To find whether a number is even or odd without using any conditional operator?? IBM4
write a function to find whether a string is palindrome or not and how many palindrome this string contain?  1
prototype of sine function. Cadence2
write a program to print the all 4digits numbers & whose squares must me even numbers? Virtusa2
what are the interview question's in the language c Nipuna1
The C language terminator is a.semicolon b.colon c.period d.exclamation mark TCS3
Write a C program that reads a series of strings and prints only those ending in "ed"  2
void main() { char far *farther,*farthest; printf("%d..%d",sizeof(farther),sizeof(farthest)); } ME3
what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason  3
const char * char * const What is the differnce between the above tow?. TCS5
how does printf function work  1
write a program in c language for the multiplication of two matrices using pointers? Ignou5
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
 
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