GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  IBM  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 35 of 98    Print  

What will the following program do?

void main()

{

int i;

char a[]="String";

char *p="New String";

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

b


  
Total Answers and Comments: 0 Last Update: N/A   
  
 Sponsored Links

 

No answers are posted for this question yet.
Be the first to answer it!


 Related Questions

Main(){printf("%u",main);}what will be the output?main(){int 1,b;int con;1=b=2;con (b==1) ? 1 : 0;printf("%d",con);} what will be the value of con?

The UNIX shell is....a).does not come with the rest of the systemb).forms the interface between the user and the kernelc) does not give any scope for programmingd) does not allow calling one program from with in anothere) all of the above
b  

Result of the following program ismain(){int i=0;for(i=0;i<20;i++){switch(i)case 0:i+=5;case 1:i+=2;case 5:i+=5;default i+=4;break;}printf("%d,",i);}}a)0,5,9,13,17b)5,9,13,17c)12,17,22d)16,21e)syntax error
d  

What is the resultmain(){char c=-64;int i=-32unsigned int u =-16;if(c>i){printf("pass1,");if(c
c  

What will the following program do?void main(){int i;char a[]="String";char *p="New String";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 8c) Generate compilation error in line number 5d) Generate compilation error in line number 7e) Generate compilation
b  

In the following code segment what will be the result of the function, value of x , value of y{unsigned int x=-1;int y;y = ~0;if(x == y)printf("same");elseprintf("not same");}a) same, MAXINT, -1b) not same, MAXINT, -MAXINTc) same , MAXUNIT, -1d) same, MAXUNIT, MAXUNITe) not same, MAXINT, MAXUNIT
a  

PATH = /bin : /usr : /yourhomeThe file /bin/calendar has the following line in itcal 10 1997The file /yourhome/calendar has the following line in itcal 5 1997If the current directory is /yourhome and calendar is executeda) The calendar for May 1997 will be printed on screenb) The calendar for Oct 1997 will be printed on screenc) The calendar for the current month( whatever it is) will be printedd) Nothing will get printed on screene) An error massage will be printed

What will be the result of the following program ?char *gxxx(){static char xxx[1024];return xxx;}main(){char *g="string";strcpy(gxxx(),g);g = gxxx();strcpy(g,"oldstring");printf("The string is : %s",gxxx());}a) The string is : stringb) The string is :Oldstringc) Run time error/Core dumpd) Syntax error during compilatione) None of these
b  

What will be result of the following program?void myalloc(char *x, int n){x= (char *)malloc(n*sizeof(char));memset(x,,n*sizeof(char));}main(){char *g="String";myalloc(g,20);strcpy(g,"Oldstring");printf("The string is %s",g);}a) The string is : Stringb) Run time error/Core dumpc) The string is : Oldstringd) Syntax error during compilatione) None of these

Which function is the entry point for a DLL in MS Windows 3.1a) mainb) Winmainc) Dllmaind) Libmaine) None
b  


 Sponsored Links

 
Related Articles

C++ Void Pointer and Null Pointer

C Void Pointer and Null Pointer In this C tutorial you will learn about two interesting types of pointers; void pointers and Null Pointer These pointers will be discussed in conjunction with syntax usage and example mosgoogle center Pointer to Void General Syntax void pointer variable; Void is use
 

C++ String Representation and Handling

C String Representation and Handling In this C tutorial you will learn about string representation and handling how is string represented end string notation initializing char array character representation string literals example programe to understand the character array concept and the accessing
 

JavaScript String Object

JavaScript String Object In this JavaScript tutorial you will learn about String Object purpose of string object in JavaScript purpose of string object indexof method lastIndexOf method and substring method along with syntax and example mosgoogle center Purpose of String Object in JavaScript The mai
 

On-Line Transaction Processing

On-Line Transaction Processing On-Line Transaction Processing is a processing that supports the daily business operations. Also know as operational processing and OLTP.&nbsp; An OLTP is a database which must typically allow the real-time processing of SQL transactions to support traditional reta
 

On-Line Analytical Processing

On-Line Analytical Processing On-Line Analytical Processing is a processing that supports the analysis of business trends and projections. It is also known as decision support processing and OLAP.&nbsp; An OLAP software enables companies to have real-time analysis of data stored in a database. A
 

Convert a String into an Integer

How to convert a string into an integer in C program? This is done by using the function named as atoi(). This function atoi() is present in the header file named as &lt;stdlib.h&gt;. When programmers use this function they must include the header file by the statement #include &lt;stdl
 

printf() Function Return Value

What is the return value from printf() function? printf function always returns the number of characters printed. Let us understand this with an example: main() { int a=10; printf(&quot;%d&quot;,printf(&quot;%d %d %d&quot;, a,a,a)); } In this above program the inner printf i
 

String handling functions

What is the string handling functions present in header file &lt;string.h&gt;? There are number of string handling functions present in string.h. In other words if a programmer uses any of the function present in string.h then they must include the header file as #include &lt;string.h&am
 

Convert a String into Long Value

What string function is used to convert a string into long value? This is done by using the function named as atol() . This function atol() is present in the header file named as &lt;stdlib.h&gt;.&nbsp;When programmers use this function they must include the header file by the statement
 

How is the main() function declared?

The declaration of main can be done as int main() One more declaration that can be taken by main is command line arguments form int main(int argc, char *argv[]) or this can also be written as int main(argc, argv) int argc; char *argv[]; NOTE: It is not possible for one to declare the main
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape