Bangalore, , India
Embedded Systems, C Language, Team Work
0 टिप्पणी करें | 77 लोगो ने देखा है | 28 जून 14  | Vishal Swaroop
C Puzzles
C-Puzzles 1 includeltstdio.hgt void main printfNULL Ans No output 2 includeltstdio.hgt void main printf,7 Ans 3 includeltstdio.hgt void main printf//,5 Ans // 4 includeltstdio.hgt void main printfd,8 Ans d 5 includeltstdio.hgt void main printfd0,123 Ans 123 6 includeltstdio.hgt void main printfd1,123 Ans d 7 includeltstdio.hgt void main printfd,printfHiprintfBye Ans HiBye6 8 includeltstdio.hgt void main printfd,printfHiprintfBye Ans HiBye9 9 includeltstdio.hgt void main printfd,printfprintf Ans 0 10 includeltstdio.hgt void main printfHi Friends3 Ans Friends 11 includeltstdio.hgt void main printfC For printfSwimmers Ans C For Swimmers 12 includeltstdio.hgt void main printf/-/ Ans /-/ 13 includeltstdio.hgt void main void main7 printfd,main return main printfBye Ans 7 14 includeltstdio.hgt void main main Ans Infinite loop/ cannot call main from within the program in function main 15 includeltstdio.hgt void main printfWork Hard Ans WorkHard 16 includeltstdio.hgt void main printf Ans Too few parameters in call to printfcnst char.. 17 includeltstdio.hgt void main int i2 printfd d d d,i,i10,i20,i Ans 11 10 23 2 18 includeltstdio.hgt void main int x1,y25 printfd,printfdd,x,y Ans 1253 19 includeltstdio.hgt void main int i3,j5 printfd,ij Ans lvalue required 20 includeltstdio.hgt void main char c8 int d8 printfd d d,d,dcgt0clt9,c Ans 9 9 56 21 includeltstdio.hgt void main char c whilecgetcharn printfd ,c I/P1234 o/p 1111 22. includeltstdio.hgt void main char c whilecgetcharn printfd ,c I/P1234 o/p49 50 51 52 23. includeltstdio.hgt void main int a3,b1 a bltlta bgtgt2 b bltlta bgtgt2 printfd d,a,b Ans 4 8 24. includeltstdio.hgt void main int i9876 printfdn,printfd,printfd,i Ans987641 25. includeltstdio.hgt void main int x2,y3,z,x12,y13,z1 zx y z1x1y1 printfxd yd zd x1d y1d z1d,x,y,z,x1,y1,z1 Ans x2 y3 z5 x13 y13 z15 26. includeltstdio.hgt define x 23 define y 45 void main int a,b axy byx printfad bd,a,b Ans a19 b17 27. includeltstdio.hgt void main int a1,b3,c2,x,y xa,b,c ya,b,c printfxd yd,x,y Ans x1 y2 28. include ltstdio.hgt void main int i0 printfd dn,scanfd,i,i printfd dn,i4,i Ans 1 0 and 4, entered value 29. includeltstdio.hgt void main int a,b,c2,d10 scanfdd,a,b,c,d printfad bd cd dd,a,b,c,d Ans aval1 bval2 c2 d10 30. includeltstdio.hgt void main int x 5,p 22 printfd,x,p Ans5 blank spaces and 22 31.includeltstdio.hgt void main char c c200 printfd,c Ans -56 32 includeltstdio.hgt void main printfHi if -1 printfBye Ans HiBye 33 includeltstdio.hgt void main printfHi if 0 -1 printfBye Ans HiBye 34 includeltstdio.hgt void main printfHi if 1 printfBye Ans Hi 35 includeltstdio.hgt void main printfHi if 0 printfBye Ans Compile time errorif statement missing 36 includeltstdio.hgt void main printfHi if -1111-1-1-1-1--1 printfBye Ans HiBye 37 includeltstdio.hgt void main if sizeofint sizeoffloat sizeoffloat/2-sizeofint printfTesting printfOK Ans OK 38 includeltstdio.hgt void main int a1,b2,c3,d4,e if ea b c d printfd,e Ans 7 39 includeltstdio.hgt void main unsigned val0xffff if val printfd,val printfd,val Ans 65535,-65536 40 includeltstdio.hgt void main unsigned a0xe75f,b0x0EF4,c cab if c gt a c gt b printfx,c Ans efff 41 includeltstdio.hgt void main unsigned val0xabcd if valgtgt16 valltlt16 printfSuccess else printfFailure Ans Success 42 includeltstdio.hgt void main unsigned x0xf880,y5,z zxltlty printfx x,z,xgtgty-1 Ans 0x1000,0xf88 43 includeltstdio.hgt void main int a1,b2,c3,d4 if d gt c if c gt b printfd d,d,c else if c gt a printfd d,c,d if c gt a if b lt a printfd d,c,a else if b lt c printfd d,b,c Ans 4 3 2 3 44 includeltstdio.hgt void main int a1,b2,c3,d4 if d gt c if c gt b printfd d,d,c if c gt a printfd d,c,d if c gt a if b lt a printfd d,c,a if b lt c printfd d,b,c Ans 4 33 42 3 45 includeltstdio.hgt void main int a if a 2 printfC Program Ans C Program 46 includeltstdio.hgt void main int a1 if a printfTest else printfAgain Ans TestAgain Important else is with also it will print TestAgain 47includeltstdio.hgt void main int i1 whileilt10 printfdn,i i Ans No O/P 48includeltstdio.hgt void main int x4 whilex1 xx-1 printfdn,x --x 49includeltstdio.hgt void main int x4,y,z y-x zx-- printfdddn,x,y,z Ans 3,-4,4 50ncludeltstdio.hgt void main whilealtb printfmalayam is a palindromen Ans Error 51includeltstdio.hgt void main int i Whilei10 printfdn,i ii1 Ans continuously printing 10. 52includeltstdio.hgt void main int x4,y3,z yx--y printfdddn,x,y,z O/P-error 53includeltstdio.hgt void main float x1.1 whilex1.1 printffn,x xx-0.1 error point. O/P-ERROR 54includeltstdio.hgt void main int x4,y0,z whilexgt0 x-- y ifxy continue else printfndd,x,y Ans 31 13 04 55includeltstdio.hgt void main int x4,y0,z whilexgt0 ifxy break else printfddn,x,y x-- y Ans 40 31 56How many times the while loop in the following statement is used to take the control to the beginning of the loop includeltstdio.hgt void main int j1 whilejlt255 printfcd,j,j j Ans No OP 57 includeltstdio.hgt void main int i1 for ilt4 i printfdn,i Ans 4 58 includeltstdio.hgt void main int a,b for a0 alt10 a for b25 bgt9 b-3 printfd d,a,b Ans 10 7 59 includeltstdio.hgt void main float i for i0.1 ilt0.4 i0.1 printf.1f ,i Ans 0.1 0.2 0.3 60 includeltstdio.hgt void main int i for i-10 i i printfd,-i Ans 10 61 includeltstdio.hgt void main int i5 do printfd,i-- while igt0 Ans Compile-time error do with 62 includeltstdio.hgt void main int i for i2,i2 ilt9 i2 printfd ,i Ans 4 6 8 63 includeltstdio.hgt void main int i3 for i-- ilt7 i7 printfd,i Ans 2 64 includeltstdio.hgt void main int i for i5 --i printfd ,i Ans 4 3 2 1 65 includeltstdio.hgt void main for printf Ans No output 66 includeltstdio.hgt void main int i for i4i-4i printfd,i Ans No output 67 includeltstdio.hgt void main char strTest if printfs,str 4 printfSuccess else printfFailure Ans TestSuccess 68 includeltstdio.hgt void main int a500,b100,c30,d40,e19 if a gt b c d gt e e lt d a / 5 b c d printfSuccess else printfFailure Ans Failure 69 include ltstdio.hgt void main int i 6 if i lt 7 i/6 i lt 9 printfdn,i Ans 8 70 include ltstdio.hgt void main int a, b, c, abc 0 a b c 40 if c int abc abc abc printf c d, abc d , c, abc Ans c40, abc0 71 include ltstdio.hgt void main int k 5 if k lt 5 k/5 k lt 8 printfd , k Ans 7 72 include ltstdio.hgt void main int k 5 if k lt 5 klt5 k lt 8 printfd , k Ans 7 73 include ltstdio.hgt void main int k 5 if kgtk printfyes Ans yes 74 includeltstdio.hgt void main char strd int val25 printfstr,val Ans 25 75 includeltstdio.hgt void main int val75 printfd,val,.,. Ans Compile-time errorexpression systax in function main 76 includeltstdio.hgt void main int val10 printfd,val1,d,val-- Ans 10 77 includeltstdio.hgt void main int val5 printfd d d d,val,--val,val,val-- Ans 4 4 5 5 78 includeltstdio.hgt void main int val5,num printfd,scanfd d,val,num Ans 2 79 includeltstdio.hgt define Computex,y,z xy-z void main int x2,y3,z4 printfd,Computey,z,-xy Computez,x,-yz Ans 30 80 includeltstdio.hgt void main int m10,n20 printfd d d,m/ m-value /,/ n-value /n,m/ Compute mn /n Ans 10 20 200 81 includeltstdio.hgt void main int m10,n20 / printfd,mn Ans Unterminated comment 82 includeltstdio.hgt void main int val97 Printing...printfc,val Ans a 83 includeltstdio.hgt void main int val5 valprintfC printfSkills printfd,val Ans Cskills7 84 includeltstdio.hgt void main int val5 printfd,val,val Ans 5 spaces5 85 includeltstdio.hgt void main int val5 printfd5,val Ans 55 86 includeltstdio.hgt void main printff,123. Ans 123.000000 87 includeltstdio.hgt void main printfd,sizeofinteger Ans compile-time errorundifined symbol integer in function main 88 includeltstdio.hgt void main char strC For Swimmers printfd,sizeof str Ans 15 89 includeltstdio.hgt void main char strC For Swimmers printfd,sizeofstr Ans Lvalue requiredcompile time error 90 includeltstdio.hgt void main char strC For Swimmers printfd,-sizeofstr Ans -15 91 includeltstdio.hgt void main printfd,1001001 Ans 1 92 includeltstdio.hgt void main int x5,y6,z2 z/y/z3y/zxy printfd,z Ans 0 93 includeltstdio.hgt void main printfd d d,5,5,25-25 Ans 5 0 25 94 includeltstdio.hgt void main int a500,b100,c30,d40,e19 ab-cd/e5 printfd d d d d,a,b,c,d,e Ans 300 -200 300 10 4 95 includeltstdio.hgt void main int a1,b2,c3,d4 printfd,abcda Ans 1 96 includeltstdio.hgt void main char strC For Swimmers printfs,str printfn.5s,str printfn8.s,5,str printfn-10s .1s,str6,str Ans C For Swimmers C For C For Swimmers C 97 includeltstdio.hgt void main int a1,b2,c3 scanfd d d,a,b,c printfad bd cd,a,b,c Ans If the 3 values entered by the user are100 200 300, the output will be 100 300 3 98 includeltstdio.hgt void main char line80 // Max. length80 Chars scanf,s,line printfns,line 99 includeltstdio.hgt void main char a,b,c scanfccc,a,b,c printfac bc cc,a,b,c Ans If the input is A B C and enter key is pressed after each char, output will be aA b cB 100 includeltstdio.hgt void main int i1 float f2.25 scanfd a f,i,f printfd .2f,i,f Ans If the input is 5 5.75, output will be 5 2.25 101 includeltstdio.hgt void main char a,b,c scanfc c c,a,b,c printfac bc cc,a,b,c Ans If the input is ABC DEF GHI, output will be aA bB cC 102 includeltstdio.hgt void main char a80,b80,c80 scanf1s 5s 3s,a,b,c printfs s s,a,b,c Ans If the input is CmeansSeaOcean Vast , output will be C Means Sea 103 includeltstdio.hgt void main int a,b,c scanf1d 2d 3d,a,b,c printfSumd,abc Ans If the user input is 123456 44 445 , output will be 480 104 includeltstdio.hgt void main char line80 scanf1234567890n,line printfs,line Ans Accepts the string that contains anything other than the DIGITS and NEWLINE characters. 105 includeltstdio.hgt void main char line80 scanf,line Ans Accepts the string that contains anything other than the . 106 include ltstdio.hgt void main int i43 printfdn,printfd,printfd,i Ans 4321 107 include ltstdio.hgt void main float a 12.5 printfdn, a Ans 0 108 include ltstdio.hgt void main char str8 printfEnter the string scanfs,str printfYou enteredsn,str Ans if the user input is good morning, it will print good. 109 include ltstdio.hgt void main int i i 10 printfd ,i printfd ,sizeofi printfd,i Ans 10 2 10 110 include ltstdio.hgt void main int val1234 int ptrval printfd d,val,ptr Ans 1235 1234 111 include ltstdio.hgt void main int val1234 int ptrval printfd d,val,ptr Ans 1234 1234 112 include ltstdio.hgt void main int val1234 int ptrval printfd d,val,ptr Ans 1235 1235 113 include ltstdio.hgt void main int val1234 int ptrval printfd d,val,ptr Ans 1235 1234 114 include ltstdio.hgt void main int val1234 int ptrval printfd d,val,int ptr-- Ans 1234 1234 115 include ltstdio.hgt void main int a555,ptra,bptr printfd d d,a,--b,ptr Ans 556 554 555 116 include ltstdio.hgt void main int a555,bptr,ptra printfd d d,a,--b,ptr Ans Compile-time error 117 include ltstdio.hgt void main int a555,ptra,bptr printfd d d,a,--b,ptr Ans 555 554 555 118 include ltstdio.hgt void main int a555,ptra,bptr777 printfd d,--b,int b Ans 776 777 119 include ltstdio.hgt void main int a5u,b,c,d,e ba cb dc ed printfu u u u,b-5,c-11,d-6,65535e Ans 0 65530 65535 4 110 include ltstdio.hgt void main float val5.75 int ptrval printf.2f .2f,float ptr,val Ans errorcannot convert floatss to int 111 include ltstdio.hgt void main int val50 const int ptr1val int const ptr2ptr1 printfd d d,val,ptr1,ptr2 int ptr198 printfnd d d,val,ptr1,ptr2 Ans 51 50 50 99 98 98 112 include ltstdio.hgt void main int val77 const int ptr1val int const ptr2ptr1 printfd d d,--val,ptr1,ptr2 Ans Errorcannot modify a constant object in printf 113 include ltstdio.hgt void main int a50,b60 int const ptr1a printfd d,--a,ptr1 ptr1b printfnd d,b,ptr1 Ans Errorcannot modify a constant object 114 include ltstdio.hgt void main int a50 const int const ptra printfd d,ptr,ptr Ans Errorcannot modify a constant object 115 include ltstdio.hgt void main int val77 const int const ptrval printfd,ptr Ans 77 116 include ltstdio.hgt void main int a1,2,3,4,5,6 int ptra2 printfd d,--ptr1,1--ptr Ans 2 3 117 include ltstdio.hgt void main int a1,2,3,4,5,6 int ptra2 printfd d,a,--ptr Ans ErrorLvalue required in function main 118 include ltstdio.hgt void main int matrix231,2,3,4,5,6 printfd d dn,matrix,matrix12,matrix1 printfd d d,matrix02,matrix11,matrix1 Ans 1 6 2 3 5 4 119 include ltstdio.hgt void main int a5 printfd d,sizeofa,sizeofa Ans 10 4 120includeltstdio.hgt void funint,int void main int i5,j2 funI,j printfddn,I,j void funint I,int j iij jjj 121includeltstdio.hgt void funint,int void main int i5,j2 funI,j printfddn,I,j void funintI,intj iiI jjj 122 includeltstdio.hgt struct int i float f var void main var.i5 var.f9.76723 printfd .2f,var.i,var.f Ans 5 9.77 123 includeltstdio.hgt struct values int i float f void main struct values var555,67.05501 printf2d .2f,var.i,var.f Ans 555 67.06 124 includeltstdio.hgt typedef struct int i float f values void main static values var555,67.05501 printf2d .2f,var.i,var.f Ans 555 67.06 125 includeltstdio.hgt struct mystruct int i7 float f999.99 var void main var.i5 printfd .2f,var.i,var.f Ans Error, cannot initialize a class member here 126 includeltstdio.hgt struct first int a float b s132760,12345.12345 typedef struct char a int b second struct mystruct float a unsigned int b typedef struct mystruct third void main static second s2A,- -4 third s3 s3.as1.a-32760 s3.b-s2.b printfd .2fnc dn.2f u,s1.a--,s1.b0.005,s2.a32,s2.b,s3.a,--s3.b Ans 32760 12345.13 a 5 0.00 65530 127 includeltstdio.hgt struct int i,val25 var1,2,3,4,5,6,7,8,9,vptrvar void main printfd d dn,var.i,vptr-gti,vptr.i printfd d d d d d,var.val4,var.val4,vptr-gtval4,vptr- gtval4,vptr.val4,vptr.val4 Ans 1 1 1 6 6 6 6 6 6 128 includeltstdio.hgt typedef struct int i float f temp void altertemp ptr,int x,float y ptr-gtix ptr-gtfy void main temp a111,777.007 printfd .2fn,a.i,a.f altera,222,666.006 printfd .2f,a.i,a.f Ans 111 777.01 222 666.01 129 includeltstdio.hgt typedef struct int i float f temp temp altertemp tmp,int x,float y tmp.ix tmp.fy return tmp void main temp a111,777.007 printfd .3fn,a.i,a.f aaltera,222,666.006 printfd .3f,a.i,a.f Ans 111 777.007 222 666.006 130 includeltstdio.hgt typedef struct int i float f temp temp altertemp ptr,int x,float y temp tmpptr printfd .2fn,tmp.i,tmp.f tmp.ix tmp.fy return tmp void main temp a65535,777.777 aaltera,-1,666.666 printfd .2f,a.i,a.f Ans -1 777.78 -1 666.67 131 includeltstdio.hgt struct mystruct1 int arr22 typedef struct mystruct1 record struct mystruct2 record temp list21,2,3,4,5,6,7,8 void main int i,j,k for i1 igt0 i-- for j0 jlt2 j for k1 kgt0 k-- printfd,listi.temp.arrjk Ans 65872143 132 includeltstdio.hgt struct mystruct int i unsigned int j void main struct mystruct temp1-32769,-1,temp2 temp2temp1 printfd u,temp2.i,temp2.j Ans 32767 65535 133 includeltstdio.hgt union A char ch int i float f tempA void main tempA.chA tempA.i777 tempA.f12345.12345 printfd,tempA.i Ans -7042 134 includeltstdio.hgt struct A int i float f union B char ch int j temp temp1 void main struct A temp25 printfd d,sizeof temp1,sizeoftemp2 Ans 8 40 135 includeltstdio.hgt void main static struct mystruct unsigned a1 unsigned b2 unsigned c3 unsigned d4 unsigned 6 // Fill out first word v1,2,7,12 printfd d d d,v.a,v.b,v.c,v.d printfnSized bytes,sizeof v Ans 1 2 7 12 Size2 bytes 136includeltstdio.hgt void main struct sample unsigned a1 unsigned b4 v0,15 unsigned vptrv.b printfd d,v.b,vptr Ans ErrorIllegel to take address of bit field in function main 137 includeltstdio.hgt void main static struct mystruct unsigned a1 int i unsigned b4 unsigned c10 v1,10000,15,555 printfd d d d,v.i,v.a,v.b,v.c printfnSized bytes,sizeof v Ans 10000 1 15 555 Size5 bytes

    • इस ब्लॉग के लिए सामाजिक शेयर

पोर्फोलिओ और ब्लॉग
Vishal Swaroop विभिन्न कंपनियों का अनुसरण करता है, ये कंपनियां और नियोक्ता Vishal के फिर से शुरू देख सकते हैं
सबसे अच्छा नौकरी के अवसर पाने के लिए अपना फिर से शुरू करें अपलोड करें

मुफ्त रजिस्टर करें!