Kiransrinivas.files.wordpress.com



(1)What will be output of following c code?#include<stdio.h>extern?int?x;int?main(){????do{??? ????do{???????????? printf("%o",x);???????? }?????????while(!-2);??? }????while(0);????return?0;}int?x=8;(2)What will be output of following c code?????????#include<stdio.h>int?main(){????int?i=2,j=2;????while(i+1?--i:j++)???????? printf("%d",i);????return?0;}(3)What will be output of following c code?#include<stdio.h>int?main(){????int?x=011,i;????for(i=0;i<x;i+=3){???????? printf("Start ");?????????continue;???????? printf("End");??? }????return?0;}(4)What will be output of following c code?#include<stdio.h>int?main(){????int?i,j;??? i=j=2,3;????while(--i&&j++)???????? printf("%d %d",i,j);????return?0;}(5)What will be output of following c code?#include<stdio.h>int?main(){????static?int?i;????for(++i;++i;++i) {???????? printf("%d ",i);?????????if(i==4)?break;??? }????return?0;}(6)What will be output of following c code?#include<stdio.h>int?main(){????int?i=1;????for(i=0;i=-1;i=1) {???????? printf("%d ",i);?????????if(i!=1)?break;??? }????return?0;}(7)What will be output of following c code?#include<stdio.h>int?main(){????for(;;) {???????? printf("%d ",10);??? }????return?0;}(8)What will be output of following c code?????????#include<stdio.h>int?r();int?main(){????for(r();r();r()) {???????? printf("%d ",r());??? }????return?0;}int?r(){????int?static?num=7;????return?num--;}(9)What will be output of following c code?????????#include<stdio.h>#define?p(a,b) a##b#define?call(x) #xint?main(){????do{?????????int?i=15,j=3;???????? printf("%d",p(i-+,+j));??? }????while(*(call(625)+3));????return?0;}(10)#include<stdio.h>int?main(){????int?i;????for(i=0;i<=5;i++);??? printf("%d",i)????return?0;}12)What will be output of following c code?#include<stdio.h>char?_x_(int,...);int?main(){????char?(*p)(int,...)=&_x_;????for(;(*p)(0,1,2,3,4); )???????? printf("%d",!+2);????return?0;}char?_x_(int?a,...){????static?i=-1;????return?i+++a;}(13)What will be output of following c code?#include<stdio.h>int?main(){????int?i;????for(i=10;i<=15;i++){?????????while(i){?????????????do{???????????????? printf("%d ",1);?????????????????if(i>>1)??????????????????????continue;???????????? }while(0);?????????????break;???????? }??? }????return?0;}(14)How many times this loop will execute?#include<stdio.h>int?main(){????char?c=125;????do???????? printf("%d ",c);????while(c++);????return?0;}(15)What will be output of following c code?????????#include<stdio.h>int?main(){????int?x=123;????int?i={???????? printf("c"?"++")??? };????for(x=0;x<=i;x++){???????? printf("%x ",x);??? }????return?0;}16 What is the output of this C code?????(Assuming size of int be 4) #include <stdio.h> struct temp { int a; int b; int c; } p[] = {0}; main() { printf("%d", sizeof(p)); }a)4b)12c)16d)Can’t be estimated due to ambigous initialization of array17. What is the output of this C code? #include <stdio.h> struct student { char *name; }; struct student s[2]; void main() { s[0].name = "alan"; s[1] = s[0]; printf("%s%s", s[0].name, s[1].name); s[1].name = "turing"; printf("%s%s", s[0].name, s[1].name); }a) alan alan alan turingb) alan alan turing turingc) alan turing alan turingd) Run time error18. What is the output of this C code? #include <stdio.h> struct student { char *name; }; struct student s[2], r[2]; void main() { s[0].name = "alan"; s[1] = s[0]; r = s; printf("%s%s", r[0].name, r[1].name); }a) alan alanb) Compile time errorc) Variesd) Nothing19. What is the output of this C code? #include <stdio.h> struct student { char *name; }; void main() { struct student s[2], r[2]; s[1] = s[0] = "alan"; printf("%s%s", s[0].name, s[1].name); }a) alan alanb) Nothingc) Compile time errord) Varies20. What is the output of this C code? #include <stdio.h> struct student { }; void main() { struct student s[2]; printf("%d", sizeof(s)); }a)2b)4c)8d) 0. 21)Comment on the output of following C program? #include <stdio.h> main() { int a = 1; printf("size of a is %d, ", sizeof(++a)); printf("value of a is %d", a); };a. size of a is 4, value of a is 1b. size of a is 4, value of a is 2c. size of a is 2, value of a is 2d. size of a is 2, value of a is 222. Which among the following is right?a. sizeof(struct stemp*) > sizeof(union utemp*) > sizeof(char *)b. sizeof(struct stemp*) < sizeof(union utemp*) < sizeof(char *)c. sizeof(struct stemp*) = sizeof(union utemp*) = sizeof(char *)d. The order Depends on the compiler23. Comment on the following C code? #include <stdio.h> printf("%d", sizeof(strlen("HELLOWORLD")));a. Output, 4b. Output, 10c. Output, 16d. Error, sizeof cannot evaluate size of a function.24. Which of the following cannot be used inside sizeof?a.pointersb.functionsc.macro definitiond.None of the mentioned25. Comment on the following C code? #include <stdio.h> (sizeof double = 8, float = 4, void = 1) #define PI 3.14 int main() { printf("%d", sizeof(PI)); }a. Output is 8b. Output is 4c. Output is 1d. Error, we can’t use sizeof on macro-definitions. 26)What is the output of this C code? #include <stdio.h> struct p { int x; char y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / 3); if (x == sizeof(int) + sizeof(char)) printf("%d\n", ptr1->x); else printf("falsen"); }a)Compiletimeerrorb)1c)Undefinedbehaviourd)false27. What is the output of this C code? #include <stdio.h> struct p { int x; char y; }; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; struct p *ptr1 = p1; int x = (sizeof(p1) / sizeof(ptr1)); if (x == 1) printf("%d\n", ptr1->x); else printf("false\n"); }a)Compiletimeerrorb)1c)falsed)Undefinedbehaviour28. What is the output of this C code? #include <stdio.h> struct p { int x; char y; }; typedef struct p* q*; int main() { struct p p1[] = {1, 92, 3, 94, 5, 96}; q ptr1 = p1; printf("%d\n", ptr1->x); }a)Compiletimeerrorb)1c)Undefinedbehaviourd)Segmentationfault29. What is the output of this C code? #include <stdio.h> struct p { int x; char y; }; void foo(struct p* ); int main() { typedef struct p* q; struct p p1[] = {1, 92, 3, 94, 5, 96}; foo(p1); } void foo(struct p* p1) { q ptr1 = p1; printf("%d\n", ptr1->x); }a)Compiletimeerrorb)1c)Segmentationfaultd) Undefined behaviour30)what is the output of this C code? #include <stdio.h> void main() { char *a[10] = {"hi", "hello", "how"}; int i = 0, j = 0; a[0] = "hey"; for (i = 0;i < 10; i++) printf("%s\n", a[i]); }a) hi hello how Segmentation faultb) hi hello how followed by 7 null valuesc) hey hello how Segmentation faultd) Depends on compiler31. What is the output of this C code? #include <stdio.h> void main() { char *a[10] = {"hi", "hello", "how"}; printf("%d\n", sizeof(a)); }a)10b)13c)Runtimeerrord) 4032 What will be the output of following program ?123456789101112#include <stdio.h>int main(){????static int var[5];????int count=0;?????????var[++count]=++count;????for(count=0;count<5;count++)????????printf("%d ",var[count]);?????????return 0;}0 1 0 0 00 2 0 0 00 0 2 0 00 0 0 0 032) What will be the output of following program ?12345678#include <stdio.h>int main(){????int MAX=10;????int array[MAX];????printf("size of array is = %d",sizeof(array);????return 0;}size of array is = 20size of array is = 40size of array is = 4Error33) What will be the output of following program ?12345678#include <stdio.h>#define MAX 10int main(){?? int array[MAX]={1,2,3},tally;????for(tally=0;tally< sizeof(array)/sizeof(int);tally+=1)????????printf("%d ",*(tally+array));????return 0;}Error1 3 4 5 6 7 8 9 10 111 2 3 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 034) What will be the output of following program ?1234567#include <stdio.h>int main(){?? static int x[]={'A','B','C','D','E'},tally;????for(tally=0;tally< sizeof(x)/sizeof(int) ; tally+=1)????????printf("%c,%c,%c\n",*(x+tally)+1,x[tally]+1,*(tally+x)+1);????return 0;}ErrorA,A,AB,B,BC,C,CD,D,DE,E,EB,B,BC,C,CD,D,DE,E,EF,F,FE,E,ED,D,DC,C,CB,B,BA,A,A35) What will be the output of following program ?123456#include <stdio.h>int main(){?? static int array[]={10,20,30,40,50};????printf("%d...%d",*array,*(array+3)* *array);????return 0;}Error10...4010...30010....40036) What will be the output of following program ?123456789101112#include <stdio.h>int main(){?? int a[5]={1,2,3,4,5},b[5]={10,20,30,40,50},tally;?????????for(tally=0;tally< 5;++tally)????????*(a+tally)=*(tally+a)+ *(b+tally);?????????for(tally=0;tally< 5;tally++)????????printf("%d ",*(a+tally));?????return 0;}1 2 3 4 510 20 30 40 5011 22 33 44 55Error ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download