<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: FAQ for problem setters</title>
	<atom:link href="http://blog.codechef.com/2009/07/24/faq-for-problem-setters/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.codechef.com/2009/07/24/faq-for-problem-setters/</link>
	<description>Practice. Compete. Discuss.</description>
	<lastBuildDate>Sun, 12 Feb 2012 15:11:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Manish C</title>
		<link>http://blog.codechef.com/2009/07/24/faq-for-problem-setters/#comment-289</link>
		<dc:creator>Manish C</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:26:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=336#comment-289</guid>
		<description>hi,&lt;br&gt;  My programming is not so strong so i m posting some questions of C &amp; C++ so please mail me the solutions at the earliest&lt;br&gt;C,C++ Questions&lt;br&gt;1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived &lt;br&gt;object,. calling of that virtual method will result in which method being called?  &lt;br&gt;a. Base method &lt;br&gt;b. Derived method..&lt;br&gt;2. For the following C program&lt;br&gt;#define AREA(x)(3.14*x*x)&lt;br&gt;main()&lt;br&gt;{float r1=6.25,r2=2.5,a;&lt;br&gt;a=AREA(r1);&lt;br&gt;printf(&quot;n Area of the circle is %f&quot;, a);&lt;br&gt;a=AREA(r2);&lt;br&gt;printf(&quot;n Area of the circle is %f&quot;, a);&lt;br&gt;}&lt;br&gt;What is the output?&lt;br&gt;3. What do the following statements indicate. Explain. &lt;br&gt;•	int(*p)[10] &lt;br&gt;•	int*f() &lt;br&gt;•	int(*pf)() &lt;br&gt;•	int*p[10] &lt;br&gt;4.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int d=5;&lt;br&gt;printf(&quot;%f&quot;,d);&lt;br&gt;}&lt;br&gt;5. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;for(i=1;i k=255; */&lt;br&gt;signed j=-1; /* char k= -1 =&gt; k=65535 */&lt;br&gt;/* unsigned or signed int k= -1 =&gt;k=65535 */&lt;br&gt;if(ij)&lt;br&gt;printf(&quot;greater&quot;);&lt;br&gt;else&lt;br&gt;if(i==j)&lt;br&gt;printf(&quot;equal&quot;);&lt;br&gt;}&lt;br&gt;8.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;float j;&lt;br&gt;j=1000*1000;&lt;br&gt;printf(&quot;%f&quot;,j);&lt;br&gt;}&lt;br&gt;&lt;br&gt;1. 1000000&lt;br&gt;2. Overflow&lt;br&gt;3. Error&lt;br&gt;4. None &lt;br&gt;9.  How do you declare an array of N pointers to functions returning&lt;br&gt;     pointers to functions returning pointers to characters?&lt;br&gt;&lt;br&gt;10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.&lt;br&gt;    Write the way to initialize the 2nd element to 10.&lt;br&gt;&lt;br&gt;11. In the above question an array of pointers is declared.&lt;br&gt;    Write the statement to initialize the 3rd element of the 2 element to 10;&lt;br&gt;&lt;br&gt;12.&lt;br&gt;int f()&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;f(1);&lt;br&gt;f(1,2);&lt;br&gt;f(1,2,3);&lt;br&gt;}&lt;br&gt;f(int i,int j,int k)&lt;br&gt;{&lt;br&gt;printf(&quot;%d %d %d&quot;,i,j,k);&lt;br&gt;}&lt;br&gt;&lt;br&gt;What are the number of syntax errors in the above? &lt;br&gt;&lt;br&gt;&lt;br&gt;13. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i=7;&lt;br&gt;printf(&quot;%d&quot;,i++*i++);&lt;br&gt;}&lt;br&gt;&lt;br&gt; 14. &lt;br&gt;#define one 0&lt;br&gt;#ifdef one &lt;br&gt;printf(&quot;one is defined &quot;);&lt;br&gt;#ifndef one&lt;br&gt;printf(&quot;one is not defined &quot;);&lt;br&gt;&lt;br&gt; 15.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int count=10,*temp,sum=0;&lt;br&gt;temp=&amp;count;&lt;br&gt;*temp=20;&lt;br&gt;temp=&#8721;&lt;br&gt;*temp=count;&lt;br&gt;printf(&quot;%d %d %d &quot;,count,*temp,sum);&lt;br&gt;}&lt;br&gt;&lt;br&gt; 16. There was question in c working only on unix machine with pattern matching.&lt;br&gt;&lt;br&gt;&lt;br&gt;14. what is alloca()&lt;br&gt;17. &lt;br&gt;main()&lt;br&gt;{&lt;br&gt;static i=3;&lt;br&gt;printf(&quot;%d&quot;,i--);&lt;br&gt;return i&gt;0 ? main():0;&lt;br&gt;}&lt;br&gt;&lt;br&gt; 18. &lt;br&gt;char *foo()&lt;br&gt;{&lt;br&gt;char result[100]);&lt;br&gt;strcpy(result,&quot;anything is good&quot;);&lt;br&gt;return(result);&lt;br&gt;}&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;char *j;&lt;br&gt;j=foo()&lt;br&gt;printf(&quot;%s&quot;,j);&lt;br&gt;}&lt;br&gt;&lt;br&gt;19.&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;char *s[]={ &quot;dharma&quot;,&quot;hewlett-packard&quot;,&quot;siemens&quot;,&quot;ibm&quot;};&lt;br&gt;char **p;&lt;br&gt;p=s;&lt;br&gt;printf(&quot;%s&quot;,++*p);&lt;br&gt;printf(&quot;%s&quot;,*p++);&lt;br&gt;printf(&quot;%s&quot;,++*p);&lt;br&gt;}&lt;br&gt;20. Output of the following program is&lt;br&gt;main()&lt;br&gt;{int i=0;&lt;br&gt;for(i=0;ii)&lt;br&gt;{printf(&quot;pass1,&quot;);&lt;br&gt;if(c&lt;u)&lt;br&gt;printf(&quot;pass2&quot;);&lt;br&gt;else&lt;br&gt;printf(&quot;Fail2&quot;);&lt;br&gt;}&lt;br&gt;else&lt;br&gt;printf(&quot;Fail1);&lt;br&gt;if(i&lt;u)&lt;br&gt;printf(&quot;pass2&quot;);&lt;br&gt;else&lt;br&gt;printf(&quot;Fail2&quot;)&lt;br&gt;}&lt;br&gt;a) Pass1,Pass2&lt;br&gt;b) Pass1,Fail2&lt;br&gt;c) Fail1,Pass2&lt;br&gt;d) Fail1,Fail2&lt;br&gt;e) None of these&lt;br&gt;22. What will the following program do?&lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i;&lt;br&gt;char a[]=&quot;String&quot;;&lt;br&gt;char *p=&quot;New Sring&quot;;&lt;br&gt;char *Temp;&lt;br&gt;Temp=a;&lt;br&gt;a=malloc(strlen(p) + 1);&lt;br&gt;strcpy(a,p); //Line number:9//&lt;br&gt;p = malloc(strlen(Temp) + 1);&lt;br&gt;strcpy(p,Temp);&lt;br&gt;printf(&quot;(%s, %s)&quot;,a,p);&lt;br&gt;free(p);&lt;br&gt;free(a);&lt;br&gt;} //Line number 15//&lt;br&gt;a) Swap contents of p &amp; a and print:(New string, string)&lt;br&gt;b) Generate compilation error in line number 8&lt;br&gt;c) Generate compilation error in line number 5&lt;br&gt;d) Generate compilation error in line number 7&lt;br&gt;e) Generate compilation error in line number 1&lt;br&gt;23. In the following code segment what will be the result of the function, &lt;br&gt;value of x , value of y&lt;br&gt;{unsigned int x=-1;&lt;br&gt;int y;&lt;br&gt;y = ~0;&lt;br&gt;if(x == y)&lt;br&gt;printf(&quot;same&quot;);&lt;br&gt;else&lt;br&gt;printf(&quot;not same&quot;);&lt;br&gt;}&lt;br&gt;a) same, MAXINT, -1&lt;br&gt;b) not same, MAXINT, -MAXINT&lt;br&gt;c) same , MAXUNIT, -1&lt;br&gt;d) same, MAXUNIT, MAXUNIT&lt;br&gt;e) not same, MAXINT, MAXUNIT&lt;br&gt;24. What will be the result of the following program ?&lt;br&gt;char *gxxx()&lt;br&gt;{static char xxx[1024];&lt;br&gt;return xxx;&lt;br&gt;}&lt;br&gt;main()&lt;br&gt;{char *g=&quot;string&quot;;&lt;br&gt;strcpy(gxxx(),g);&lt;br&gt;g = gxxx();&lt;br&gt;strcpy(g,&quot;oldstring&quot;);&lt;br&gt;printf(&quot;The string is : %s&quot;,gxxx());&lt;br&gt;}&lt;br&gt;a) The string is : string&lt;br&gt;b) The string is :Oldstring&lt;br&gt;c) Run time error/Core dump&lt;br&gt;d) Syntax error during compilation&lt;br&gt;e) None of these&lt;br&gt;25.  Find the output for the following C program &lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *p1=&quot;Name&quot;;&lt;br&gt;char *p2;&lt;br&gt;p2=(char *)malloc(20);&lt;br&gt;while(*p2++=*p1++);&lt;br&gt;printf(&quot;%sn&quot;,p2);&lt;br&gt;}&lt;br&gt;26.  Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=20,y=35;&lt;br&gt;x = y++ + x++;&lt;br&gt;y = ++y + ++x;&lt;br&gt;printf(&quot;%d %dn&quot;,x,y);&lt;br&gt;}&lt;br&gt;27.  Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5;&lt;br&gt;printf(&quot;%d %d %dn&quot;,x,x&lt;&gt;2);&lt;br&gt;}&lt;br&gt;28 Find the output for the following C program&lt;br&gt;#define swap1(a,b) a=a+b;b=a-b;a=a-b;&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;int x=5,y=10;&lt;br&gt;swap1(x,y);&lt;br&gt;printf(&quot;%d %dn&quot;,x,y);&lt;br&gt;swap2(x,y);&lt;br&gt;printf(&quot;%d %dn&quot;,x,y);&lt;br&gt;}&lt;br&gt;int swap2(int a,int b)&lt;br&gt;{&lt;br&gt;int temp;&lt;br&gt;temp=a;&lt;br&gt;b=a;&lt;br&gt;a=temp;&lt;br&gt;return;&lt;br&gt;}&lt;br&gt;29 Find the output for the following C program&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *ptr = &quot;Ramco Systems&quot;;&lt;br&gt;(*ptr)++;&lt;br&gt;printf(&quot;%sn&quot;,ptr);&lt;br&gt;ptr++;&lt;br&gt;printf(&quot;%sn&quot;,ptr);&lt;br&gt;}&lt;br&gt;30 Find the output for the following C program&lt;br&gt;#include&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char s1[]=&quot;Ramco&quot;;&lt;br&gt;char s2[]=&quot;Systems&quot;;&lt;br&gt;s1=s2;&lt;br&gt;printf(&quot;%s&quot;,s1);&lt;br&gt;}&lt;br&gt;31 Find the output for the following C program&lt;br&gt;#include&lt;br&gt;main()&lt;br&gt;{&lt;br&gt;char *p1;&lt;br&gt;char *p2;&lt;br&gt;p1=(char *) malloc(25);&lt;br&gt;p2=(char *) malloc(25);&lt;br&gt;strcpy(p1,&quot;Ramco&quot;);&lt;br&gt;strcpy(p2,&quot;Systems&quot;);&lt;br&gt;strcat(p1,p2);&lt;br&gt;printf(&quot;%s&quot;,p1);&lt;br&gt;}&lt;br&gt;32.  Find the output for the following C program given that&lt;br&gt;[1]. The following variable is available in file1.c&lt;br&gt;static int average_float;&lt;br&gt;33.  Find the output for the following C program&lt;br&gt;# define TRUE 0&lt;br&gt;some code&lt;br&gt;while(TRUE)&lt;br&gt;{&lt;br&gt;some code &lt;br&gt;}&lt;br&gt;34. struct list{&lt;br&gt;       int x; &lt;br&gt;      struct list *next; &lt;br&gt;      }*head; &lt;br&gt;&lt;br&gt;        the struct head.x =100 &lt;br&gt;&lt;br&gt;       Is the above assignment to pointer is correct or wrong ?&lt;br&gt;35.What is the output of the following ? &lt;br&gt;&lt;br&gt;      int i; &lt;br&gt;      i=1; &lt;br&gt;      i=i+2*i++; &lt;br&gt;      printf(%d,i);&lt;br&gt;36. FILE *fp1,*fp2; &lt;br&gt;      &lt;br&gt;      fp1=fopen(&quot;one&quot;,&quot;w&quot;) &lt;br&gt;      fp2=fopen(&quot;one&quot;,&quot;w&quot;) &lt;br&gt;      fputc(&#039;A&#039;,fp1) &lt;br&gt;      fputc(&#039;B&#039;,fp2) &lt;br&gt;      fclose(fp1) &lt;br&gt;      fclose(fp2) &lt;br&gt;     }&lt;br&gt;&lt;br&gt;     Find the Error, If Any?&lt;br&gt;37. What are the output(s) for the following ?&lt;br&gt;38. #include&lt;br&gt;      char *f()&lt;br&gt;      {char *s=malloc(8); &lt;br&gt;        strcpy(s,&quot;goodbye&quot;);&lt;br&gt;     }&lt;br&gt;&lt;br&gt;      main()&lt;br&gt;      { &lt;br&gt;      char *f(); &lt;br&gt;      printf(&quot;%c&quot;,*f()=&#039;A&#039;);     }&lt;br&gt;&lt;br&gt;&lt;br&gt;39. #define MAN(x,y) (x)&gt;(y)?(x):(y) &lt;br&gt;      {int i=10;&lt;br&gt;      j=5;&lt;br&gt;      k=0;&lt;br&gt;      k=MAX(i++,++j);&lt;br&gt;      printf(%d %d %d %d,i,j,k);&lt;br&gt;      }&lt;br&gt;40. &lt;br&gt;void main()&lt;br&gt;{&lt;br&gt;int i=7;&lt;br&gt;printf(&quot;%d&quot;,i++*i++);&lt;br&gt;}</description>
		<content:encoded><![CDATA[<p>hi,<br />  My programming is not so strong so i m posting some questions of C &amp; C++ so please mail me the solutions at the earliest<br />C,C++ Questions<br />1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived <br />object,. calling of that virtual method will result in which method being called?  <br />a. Base method <br />b. Derived method..<br />2. For the following C program<br />#define AREA(x)(3.14*x*x)<br />main()<br />{float r1=6.25,r2=2.5,a;<br />a=AREA(r1);<br />printf(&#8220;n Area of the circle is %f&#8221;, a);<br />a=AREA(r2);<br />printf(&#8220;n Area of the circle is %f&#8221;, a);<br />}<br />What is the output?<br />3. What do the following statements indicate. Explain. <br />•	int(*p)[10] <br />•	int*f() <br />•	int(*pf)() <br />•	int*p[10] <br />4.<br />void main()<br />{<br />int d=5;<br />printf(&#8220;%f&#8221;,d);<br />}<br />5. <br />void main()<br />{<br />int i;<br />for(i=1;i k=255; */<br />signed j=-1; /* char k= -1 =&gt; k=65535 */<br />/* unsigned or signed int k= -1 =&gt;k=65535 */<br />if(ij)<br />printf(&#8220;greater&#8221;);<br />else<br />if(i==j)<br />printf(&#8220;equal&#8221;);<br />}<br />8.<br />void main()<br />{<br />float j;<br />j=1000*1000;<br />printf(&#8220;%f&#8221;,j);<br />}</p>
<p>1. 1000000<br />2. Overflow<br />3. Error<br />4. None <br />9.  How do you declare an array of N pointers to functions returning<br />     pointers to functions returning pointers to characters?</p>
<p>10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.<br />    Write the way to initialize the 2nd element to 10.</p>
<p>11. In the above question an array of pointers is declared.<br />    Write the statement to initialize the 3rd element of the 2 element to 10;</p>
<p>12.<br />int f()<br />void main()<br />{<br />f(1);<br />f(1,2);<br />f(1,2,3);<br />}<br />f(int i,int j,int k)<br />{<br />printf(&#8220;%d %d %d&#8221;,i,j,k);<br />}</p>
<p>What are the number of syntax errors in the above? </p>
<p>13. <br />void main()<br />{<br />int i=7;<br />printf(&#8220;%d&#8221;,i++*i++);<br />}</p>
<p> 14. <br />#define one 0<br />#ifdef one <br />printf(&#8220;one is defined &#8220;);<br />#ifndef one<br />printf(&#8220;one is not defined &#8220;);</p>
<p> 15.<br />void main()<br />{<br />int count=10,*temp,sum=0;<br />temp=&count;<br />*temp=20;<br />temp=&sum;<br />*temp=count;<br />printf(&#8220;%d %d %d &#8220;,count,*temp,sum);<br />}</p>
<p> 16. There was question in c working only on unix machine with pattern matching.</p>
<p>14. what is alloca()<br />17. <br />main()<br />{<br />static i=3;<br />printf(&#8220;%d&#8221;,i&#8211;);<br />return i&gt;0 ? main():0;<br />}</p>
<p> 18. <br />char *foo()<br />{<br />char result[100]);<br />strcpy(result,&#8221;anything is good&#8221;);<br />return(result);<br />}<br />void main()<br />{<br />char *j;<br />j=foo()<br />printf(&#8220;%s&#8221;,j);<br />}</p>
<p>19.<br />void main()<br />{<br />char *s[]={ &#8220;dharma&#8221;,&#8221;hewlett-packard&#8221;,&#8221;siemens&#8221;,&#8221;ibm&#8221;};<br />char **p;<br />p=s;<br />printf(&#8220;%s&#8221;,++*p);<br />printf(&#8220;%s&#8221;,*p++);<br />printf(&#8220;%s&#8221;,++*p);<br />}<br />20. Output of the following program is<br />main()<br />{int i=0;<br />for(i=0;ii)<br />{printf(&#8220;pass1,&#8221;);<br />if(c&lt;u)<br />printf(&#8220;pass2&#8243;);<br />else<br />printf(&#8220;Fail2&#8243;);<br />}<br />else<br />printf(&#8220;Fail1);<br />if(i&lt;u)<br />printf(&#8220;pass2&#8243;);<br />else<br />printf(&#8220;Fail2&#8243;)<br />}<br />a) Pass1,Pass2<br />b) Pass1,Fail2<br />c) Fail1,Pass2<br />d) Fail1,Fail2<br />e) None of these<br />22. What will the following program do?<br />void main()<br />{<br />int i;<br />char a[]=&#8221;String&#8221;;<br />char *p=&#8221;New Sring&#8221;;<br />char *Temp;<br />Temp=a;<br />a=malloc(strlen(p) + 1);<br />strcpy(a,p); //Line number:9//<br />p = malloc(strlen(Temp) + 1);<br />strcpy(p,Temp);<br />printf(&#8220;(%s, %s)&#8221;,a,p);<br />free(p);<br />free(a);<br />} //Line number 15//<br />a) Swap contents of p &amp; a and print:(New string, string)<br />b) Generate compilation error in line number 8<br />c) Generate compilation error in line number 5<br />d) Generate compilation error in line number 7<br />e) Generate compilation error in line number 1<br />23. In the following code segment what will be the result of the function, <br />value of x , value of y<br />{unsigned int x=-1;<br />int y;<br />y = ~0;<br />if(x == y)<br />printf(&#8220;same&#8221;);<br />else<br />printf(&#8220;not same&#8221;);<br />}<br />a) same, MAXINT, -1<br />b) not same, MAXINT, -MAXINT<br />c) same , MAXUNIT, -1<br />d) same, MAXUNIT, MAXUNIT<br />e) not same, MAXINT, MAXUNIT<br />24. What will be the result of the following program ?<br />char *gxxx()<br />{static char xxx[1024];<br />return xxx;<br />}<br />main()<br />{char *g=&#8221;string&#8221;;<br />strcpy(gxxx(),g);<br />g = gxxx();<br />strcpy(g,&#8221;oldstring&#8221;);<br />printf(&#8220;The string is : %s&#8221;,gxxx());<br />}<br />a) The string is : string<br />b) The string is :Oldstring<br />c) Run time error/Core dump<br />d) Syntax error during compilation<br />e) None of these<br />25.  Find the output for the following C program <br />main()<br />{<br />char *p1=&#8221;Name&#8221;;<br />char *p2;<br />p2=(char *)malloc(20);<br />while(*p2++=*p1++);<br />printf(&#8220;%sn&#8221;,p2);<br />}<br />26.  Find the output for the following C program<br />main()<br />{<br />int x=20,y=35;<br />x = y++ + x++;<br />y = ++y + ++x;<br />printf(&#8220;%d %dn&#8221;,x,y);<br />}<br />27.  Find the output for the following C program<br />main()<br />{<br />int x=5;<br />printf(&#8220;%d %d %dn&#8221;,x,x&lt;&gt;2);<br />}<br />28 Find the output for the following C program<br />#define swap1(a,b) a=a+b;b=a-b;a=a-b;<br />main()<br />{<br />int x=5,y=10;<br />swap1(x,y);<br />printf(&#8220;%d %dn&#8221;,x,y);<br />swap2(x,y);<br />printf(&#8220;%d %dn&#8221;,x,y);<br />}<br />int swap2(int a,int b)<br />{<br />int temp;<br />temp=a;<br />b=a;<br />a=temp;<br />return;<br />}<br />29 Find the output for the following C program<br />main()<br />{<br />char *ptr = &#8220;Ramco Systems&#8221;;<br />(*ptr)++;<br />printf(&#8220;%sn&#8221;,ptr);<br />ptr++;<br />printf(&#8220;%sn&#8221;,ptr);<br />}<br />30 Find the output for the following C program<br />#include<br />main()<br />{<br />char s1[]=&#8221;Ramco&#8221;;<br />char s2[]=&#8221;Systems&#8221;;<br />s1=s2;<br />printf(&#8220;%s&#8221;,s1);<br />}<br />31 Find the output for the following C program<br />#include<br />main()<br />{<br />char *p1;<br />char *p2;<br />p1=(char *) malloc(25);<br />p2=(char *) malloc(25);<br />strcpy(p1,&#8221;Ramco&#8221;);<br />strcpy(p2,&#8221;Systems&#8221;);<br />strcat(p1,p2);<br />printf(&#8220;%s&#8221;,p1);<br />}<br />32.  Find the output for the following C program given that<br />[1]. The following variable is available in file1.c<br />static int average_float;<br />33.  Find the output for the following C program<br /># define TRUE 0<br />some code<br />while(TRUE)<br />{<br />some code <br />}<br />34. struct list{<br />       int x; <br />      struct list *next; <br />      }*head; </p>
<p>        the struct head.x =100 </p>
<p>       Is the above assignment to pointer is correct or wrong ?<br />35.What is the output of the following ? </p>
<p>      int i; <br />      i=1; <br />      i=i+2*i++; <br />      printf(%d,i);<br />36. FILE *fp1,*fp2; </p>
<p>      fp1=fopen(&#8220;one&#8221;,&#8221;w&#8221;) <br />      fp2=fopen(&#8220;one&#8221;,&#8221;w&#8221;) <br />      fputc(&#39;A&#39;,fp1) <br />      fputc(&#39;B&#39;,fp2) <br />      fclose(fp1) <br />      fclose(fp2) <br />     }</p>
<p>     Find the Error, If Any?<br />37. What are the output(s) for the following ?<br />38. #include<br />      char *f()<br />      {char *s=malloc(8); <br />        strcpy(s,&#8221;goodbye&#8221;);<br />     }</p>
<p>      main()<br />      { <br />      char *f(); <br />      printf(&#8220;%c&#8221;,*f()=&#39;A&#39;);     }</p>
<p>39. #define MAN(x,y) (x)&gt;(y)?(x):(y) <br />      {int i=10;<br />      j=5;<br />      k=0;<br />      k=MAX(i++,++j);<br />      printf(%d %d %d %d,i,j,k);<br />      }<br />40. <br />void main()<br />{<br />int i=7;<br />printf(&#8220;%d&#8221;,i++*i++);<br />}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manish C</title>
		<link>http://blog.codechef.com/2009/07/24/faq-for-problem-setters/#comment-1695</link>
		<dc:creator>Manish C</dc:creator>
		<pubDate>Fri, 25 Sep 2009 13:26:00 +0000</pubDate>
		<guid isPermaLink="false">http://blog.codechef.com/?p=336#comment-1695</guid>
		<description>hi,  My programming is not so strong so i m posting some questions of C &amp; C++ so please mail me the solutions at the earliestC,C++ Questions1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called?  a. Base method b. Derived method..2. For the following C program#define AREA(x)(3.14*x*x)main(){float r1=6.25,r2=2.5,a;a=AREA(r1);printf(&quot;n Area of the circle is %f&quot;, a);a=AREA(r2);printf(&quot;n Area of the circle is %f&quot;, a);}What is the output?3. What do the following statements indicate. Explain. •	int(*p)[10] •	int*f() •	int(*pf)() •	int*p[10] 4.void main(){int d=5;printf(&quot;%f&quot;,d);}5. void main(){int i;for(i=1;i k=255; */signed j=-1; /* char k= -1 =&gt; k=65535 *//* unsigned or signed int k= -1 =&gt;k=65535 */if(ij)printf(&quot;greater&quot;);elseif(i==j)printf(&quot;equal&quot;);}8.void main(){float j;j=1000*1000;printf(&quot;%f&quot;,j);}1. 10000002. Overflow3. Error4. None 9.  How do you declare an array of N pointers to functions returning     pointers to functions returning pointers to characters?10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.    Write the way to initialize the 2nd element to 10.11. In the above question an array of pointers is declared.    Write the statement to initialize the 3rd element of the 2 element to 10;12.int f()void main(){f(1);f(1,2);f(1,2,3);}f(int i,int j,int k){printf(&quot;%d %d %d&quot;,i,j,k);}What are the number of syntax errors in the above? 13. void main(){int i=7;printf(&quot;%d&quot;,i++*i++);} 14. #define one 0#ifdef one printf(&quot;one is defined &quot;);#ifndef oneprintf(&quot;one is not defined &quot;); 15.void main(){int count=10,*temp,sum=0;temp=&amp;count;*temp=20;temp=&#8721;*temp=count;printf(&quot;%d %d %d &quot;,count,*temp,sum);} 16. There was question in c working only on unix machine with pattern matching.14. what is alloca()17. main(){static i=3;printf(&quot;%d&quot;,i--);return i&gt;0 ? main():0;} 18. char *foo(){char result[100]);strcpy(result,&quot;anything is good&quot;);return(result);}void main(){char *j;j=foo()printf(&quot;%s&quot;,j);}19.void main(){char *s[]={ &quot;dharma&quot;,&quot;hewlett-packard&quot;,&quot;siemens&quot;,&quot;ibm&quot;};char **p;p=s;printf(&quot;%s&quot;,++*p);printf(&quot;%s&quot;,*p++);printf(&quot;%s&quot;,++*p);}20. Output of the following program ismain(){int i=0;for(i=0;ii){printf(&quot;pass1,&quot;);if(c&lt;u)printf(&quot;pass2&quot;);elseprintf(&quot;Fail2&quot;);}elseprintf(&quot;Fail1);if(i&lt;u)printf(&quot;pass2&quot;);elseprintf(&quot;Fail2&quot;)}a) Pass1,Pass2b) Pass1,Fail2c) Fail1,Pass2d) Fail1,Fail2e) None of these22. What will the following program do?void main(){int i;char a[]=&quot;String&quot;;char *p=&quot;New Sring&quot;;char *Temp;Temp=a;a=malloc(strlen(p) + 1);strcpy(a,p); //Line number:9//p = malloc(strlen(Temp) + 1);strcpy(p,Temp);printf(&quot;(%s, %s)&quot;,a,p);free(p);free(a);} //Line number 15//a) Swap contents of p &amp; 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 error in line number 123. 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(&quot;same&quot;);elseprintf(&quot;not same&quot;);}a) same, MAXINT, -1b) not same, MAXINT, -MAXINTc) same , MAXUNIT, -1d) same, MAXUNIT, MAXUNITe) not same, MAXINT, MAXUNIT24. What will be the result of the following program ?char *gxxx(){static char xxx[1024];return xxx;}main(){char *g=&quot;string&quot;;strcpy(gxxx(),g);g = gxxx();strcpy(g,&quot;oldstring&quot;);printf(&quot;The string is : %s&quot;,gxxx());}a) The string is : stringb) The string is :Oldstringc) Run time error/Core dumpd) Syntax error during compilatione) None of these25.  Find the output for the following C program main(){char *p1=&quot;Name&quot;;char *p2;p2=(char *)malloc(20);while(*p2++=*p1++);printf(&quot;%sn&quot;,p2);}26.  Find the output for the following C programmain(){int x=20,y=35;x = y++ + x++;y = ++y + ++x;printf(&quot;%d %dn&quot;,x,y);}27.  Find the output for the following C programmain(){int x=5;printf(&quot;%d %d %dn&quot;,x,x&lt;&gt;2);}28 Find the output for the following C program#define swap1(a,b) a=a+b;b=a-b;a=a-b;main(){int x=5,y=10;swap1(x,y);printf(&quot;%d %dn&quot;,x,y);swap2(x,y);printf(&quot;%d %dn&quot;,x,y);}int swap2(int a,int b){int temp;temp=a;b=a;a=temp;return;}29 Find the output for the following C programmain(){char *ptr = &quot;Ramco Systems&quot;;(*ptr)++;printf(&quot;%sn&quot;,ptr);ptr++;printf(&quot;%sn&quot;,ptr);}30 Find the output for the following C program#includemain(){char s1[]=&quot;Ramco&quot;;char s2[]=&quot;Systems&quot;;s1=s2;printf(&quot;%s&quot;,s1);}31 Find the output for the following C program#includemain(){char *p1;char *p2;p1=(char *) malloc(25);p2=(char *) malloc(25);strcpy(p1,&quot;Ramco&quot;);strcpy(p2,&quot;Systems&quot;);strcat(p1,p2);printf(&quot;%s&quot;,p1);}32.  Find the output for the following C program given that[1]. The following variable is available in file1.cstatic int average_float;33.  Find the output for the following C program# define TRUE 0some codewhile(TRUE){some code }34. struct list{       int x;       struct list *next;       }*head;         the struct head.x =100        Is the above assignment to pointer is correct or wrong ?35.What is the output of the following ?       int i;       i=1;       i=i+2*i++;       printf(%d,i);36. FILE *fp1,*fp2;             fp1=fopen(&quot;one&quot;,&quot;w&quot;)       fp2=fopen(&quot;one&quot;,&quot;w&quot;)       fputc(&#039;A&#039;,fp1)       fputc(&#039;B&#039;,fp2)       fclose(fp1)       fclose(fp2)      }     Find the Error, If Any?37. What are the output(s) for the following ?38. #include      char *f()      {char *s=malloc(8);         strcpy(s,&quot;goodbye&quot;);     }      main()      {       char *f();       printf(&quot;%c&quot;,*f()=&#039;A&#039;);     }39. #define MAN(x,y) (x)&gt;(y)?(x):(y)       {int i=10;      j=5;      k=0;      k=MAX(i++,++j);      printf(%d %d %d %d,i,j,k);      }40. void main(){int i=7;printf(&quot;%d&quot;,i++*i++);}</description>
		<content:encoded><![CDATA[<p>hi,  My programming is not so strong so i m posting some questions of C &amp; C++ so please mail me the solutions at the earliestC,C++ Questions1. Base class has some virtual method and derived class has a method with the same name. If we initialize the base class pointer with derived object,. calling of that virtual method will result in which method being called?  a. Base method b. Derived method..2. For the following C program#define AREA(x)(3.14*x*x)main(){float r1=6.25,r2=2.5,a;a=AREA(r1);printf(&#8220;n Area of the circle is %f&#8221;, a);a=AREA(r2);printf(&#8220;n Area of the circle is %f&#8221;, a);}What is the output?3. What do the following statements indicate. Explain. •	int(*p)[10] •	int*f() •	int(*pf)() •	int*p[10] 4.void main(){int d=5;printf(&#8220;%f&#8221;,d);}5. void main(){int i;for(i=1;i k=255; */signed j=-1; /* char k= -1 =&gt; k=65535 *//* unsigned or signed int k= -1 =&gt;k=65535 */if(ij)printf(&#8220;greater&#8221;);elseif(i==j)printf(&#8220;equal&#8221;);}8.void main(){float j;j=1000*1000;printf(&#8220;%f&#8221;,j);}1. 10000002. Overflow3. Error4. None 9.  How do you declare an array of N pointers to functions returning     pointers to functions returning pointers to characters?10. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.    Write the way to initialize the 2nd element to 10.11. In the above question an array of pointers is declared.    Write the statement to initialize the 3rd element of the 2 element to 10;12.int f()void main(){f(1);f(1,2);f(1,2,3);}f(int i,int j,int k){printf(&#8220;%d %d %d&#8221;,i,j,k);}What are the number of syntax errors in the above? 13. void main(){int i=7;printf(&#8220;%d&#8221;,i++*i++);} 14. #define one 0#ifdef one printf(&#8220;one is defined &#8220;);#ifndef oneprintf(&#8220;one is not defined &#8220;); 15.void main(){int count=10,*temp,sum=0;temp=&amp;count;*temp=20;temp=&sum;*temp=count;printf(&#8220;%d %d %d &#8220;,count,*temp,sum);} 16. There was question in c working only on unix machine with pattern matching.14. what is alloca()17. main(){static i=3;printf(&#8220;%d&#8221;,i&#8211;);return i&gt;0 ? main():0;} 18. char *foo(){char result[100]);strcpy(result,&#8221;anything is good&#8221;);return(result);}void main(){char *j;j=foo()printf(&#8220;%s&#8221;,j);}19.void main(){char *s[]={ &#8220;dharma&#8221;,&#8221;hewlett-packard&#8221;,&#8221;siemens&#8221;,&#8221;ibm&#8221;};char **p;p=s;printf(&#8220;%s&#8221;,++*p);printf(&#8220;%s&#8221;,*p++);printf(&#8220;%s&#8221;,++*p);}20. Output of the following program ismain(){int i=0;for(i=0;ii){printf(&#8220;pass1,&#8221;);if(c&lt;u)printf(&#8220;pass2&#8243;);elseprintf(&#8220;Fail2&#8243;);}elseprintf(&#8220;Fail1);if(i&lt;u)printf(&#8220;pass2&#8243;);elseprintf(&#8220;Fail2&#8243;)}a) Pass1,Pass2b) Pass1,Fail2c) Fail1,Pass2d) Fail1,Fail2e) None of these22. What will the following program do?void main(){int i;char a[]=&#8221;String&#8221;;char *p=&#8221;New Sring&#8221;;char *Temp;Temp=a;a=malloc(strlen(p) + 1);strcpy(a,p); //Line number:9//p = malloc(strlen(Temp) + 1);strcpy(p,Temp);printf(&#8220;(%s, %s)&#8221;,a,p);free(p);free(a);} //Line number 15//a) Swap contents of p &amp; 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 error in line number 123. 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(&#8220;same&#8221;);elseprintf(&#8220;not same&#8221;);}a) same, MAXINT, -1b) not same, MAXINT, -MAXINTc) same , MAXUNIT, -1d) same, MAXUNIT, MAXUNITe) not same, MAXINT, MAXUNIT24. What will be the result of the following program ?char *gxxx(){static char xxx[1024];return xxx;}main(){char *g=&#8221;string&#8221;;strcpy(gxxx(),g);g = gxxx();strcpy(g,&#8221;oldstring&#8221;);printf(&#8220;The string is : %s&#8221;,gxxx());}a) The string is : stringb) The string is :Oldstringc) Run time error/Core dumpd) Syntax error during compilatione) None of these25.  Find the output for the following C program main(){char *p1=&#8221;Name&#8221;;char *p2;p2=(char *)malloc(20);while(*p2++=*p1++);printf(&#8220;%sn&#8221;,p2);}26.  Find the output for the following C programmain(){int x=20,y=35;x = y++ + x++;y = ++y + ++x;printf(&#8220;%d %dn&#8221;,x,y);}27.  Find the output for the following C programmain(){int x=5;printf(&#8220;%d %d %dn&#8221;,x,x&lt;&gt;2);}28 Find the output for the following C program#define swap1(a,b) a=a+b;b=a-b;a=a-b;main(){int x=5,y=10;swap1(x,y);printf(&#8220;%d %dn&#8221;,x,y);swap2(x,y);printf(&#8220;%d %dn&#8221;,x,y);}int swap2(int a,int b){int temp;temp=a;b=a;a=temp;return;}29 Find the output for the following C programmain(){char *ptr = &#8220;Ramco Systems&#8221;;(*ptr)++;printf(&#8220;%sn&#8221;,ptr);ptr++;printf(&#8220;%sn&#8221;,ptr);}30 Find the output for the following C program#includemain(){char s1[]=&#8221;Ramco&#8221;;char s2[]=&#8221;Systems&#8221;;s1=s2;printf(&#8220;%s&#8221;,s1);}31 Find the output for the following C program#includemain(){char *p1;char *p2;p1=(char *) malloc(25);p2=(char *) malloc(25);strcpy(p1,&#8221;Ramco&#8221;);strcpy(p2,&#8221;Systems&#8221;);strcat(p1,p2);printf(&#8220;%s&#8221;,p1);}32.  Find the output for the following C program given that[1]. The following variable is available in file1.cstatic int average_float;33.  Find the output for the following C program# define TRUE 0some codewhile(TRUE){some code }34. struct list{       int x;       struct list *next;       }*head;         the struct head.x =100        Is the above assignment to pointer is correct or wrong ?35.What is the output of the following ?       int i;       i=1;       i=i+2*i++;       printf(%d,i);36. FILE *fp1,*fp2;             fp1=fopen(&#8220;one&#8221;,&#8221;w&#8221;)       fp2=fopen(&#8220;one&#8221;,&#8221;w&#8221;)       fputc(&#039;A&#039;,fp1)       fputc(&#039;B&#039;,fp2)       fclose(fp1)       fclose(fp2)      }     Find the Error, If Any?37. What are the output(s) for the following ?38. #include      char *f()      {char *s=malloc(8);         strcpy(s,&#8221;goodbye&#8221;);     }      main()      {       char *f();       printf(&#8220;%c&#8221;,*f()=&#039;A&#039;);     }39. #define MAN(x,y) (x)&gt;(y)?(x):(y)       {int i=10;      j=5;      k=0;      k=MAX(i++,++j);      printf(%d %d %d %d,i,j,k);      }40. void main(){int i=7;printf(&#8220;%d&#8221;,i++*i++);}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

