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

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 : string

b) The string is :Oldstring

c) Run time error/Core dump

d) Syntax error during compilation

e) None of these

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  

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  

compiler dependent  
Latest Answer : Compiler dependent.The output is obtained based on how the compiler traverse from left to right or right to left. ...


 Sponsored Links

 
Related Articles

C++ Static Functions

C Static Functions Static member functions have a class scope and they do not have access to the this pointer of the class When a member is declared as static a static member of class it has only one data for the entire class even though there are many objects created for the class The main usage of
 

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
 

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
 

What happens when a variable is not initialized in main function?

When a variable is not initialized in main function it contains garbage value. This can be well seen from the example below main() { int x; printf(&ldquo;%d&rdquo;,x); z= sample() } sample() { printf(&ldquo;Testing program&rdquo;); } Output is &nbsp;&nbsp;&n
 

What is the default return value of a function?

The default return value from a function is int. In other words, unless explicitly specified the default return value by compiler would be integer value from function.&nbsp;&nbsp; When a programmer wants other than integer values to be returned from function then it is essential that the pro
 

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