C Quiz

725 views

Published on

play a free C Language Quiz by choosing levels & test your knowledge.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
725
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
69
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • 158- 159, 162, 165
  • 168, 171, 174
  • 177, 180, 183
  • 186, 189, 192
  • C Quiz

    1. 1. Anjuman College of Engineering and Technology, Sadar, Nagpur.Computer Science and engineering department presents Envisage’13 “Over C War” By, Shabina Parveen Powerpoint Templates Page 1
    2. 2. RULES Each Easy level question consists of 5 marks.Each Medium level question consists of 10 marksEach Hard level question consists of 15 marksAccording to the level chosen for betting, for each correct answer plus marks & for each wrong answer respective marks will be deducted from the actual score Powerpoint Templates Page 2
    3. 3. Categories Easy Medium Hard Powerpoint Templates Page 3
    4. 4. QuestionPowerpoint Templates Page 4
    5. 5. AnswerDennis Ritchie… Powerpoint Templates Page 5
    6. 6. Categories Easy Medium Hard Powerpoint Templates Page 6
    7. 7. QuestionWould the following program give a compilation error or warning? #include<stdio.h> int main() { float I =10, *j; void *k; k = &I; j = k; printf(“%fn”, *j); return 0; } a. Yes Powerpoint Templates b. No Page 7
    8. 8. Answer b. NoPowerpoint Templates Page 8
    9. 9. Categories Easy Medium Hard Powerpoint Templates Page 9
    10. 10. QuestionPredict the output:# define SQUARE(x) x*x;inline float square(float y){return y*y;}int main(){float a = 0.5, b = 0.5, c, d;c= SQUARE (++a)l;d = square (++b);return 0; Powerpoint Templates} Page 10
    11. 11. AnswerOutput: during preprocessing themacro SQUARE gets expandedinto c=++x *++x;You can notice the undesirableside effect in this macro expansion;the output is unpredictablebecause such side effect must notappear in inline function. Powerpoint Templates Page 11
    12. 12. Categories Easy Medium Hard Powerpoint Templates Page 12
    13. 13. Question Which of the following statement is true about the >> operator?a. It divides a positive value by a power of two.b. It multiplies a positive value by a power of two.c. It adds a positive value with a power of two.d. It subtracts from a positive value a Powerpoint Templates power of two. Page 13
    14. 14. Answera. It divides a positive value by a power of two. Powerpoint Templates Page 14
    15. 15. Categories Easy Medium Hard Powerpoint Templates Page 15
    16. 16. Questionwould the following code compile?#include<stdio.h>int main(){int a = 10, *j; a. Yesvoid *k; b. noj= k = &a;j++;k++;printf(“%u %un , j, k”);return 0; Powerpoint Templates} Page 16
    17. 17. Answer b. NoPowerpoint Templates Page 17
    18. 18. Categories Easy Medium Hard Powerpoint Templates Page 18
    19. 19. QuestionPredict the output:#include<stdio.h>int main(){int a[]={0,1,2,3.4};int i , *p;for(p=arr,i=0; p+i<=arr+4 ; p++ , i++) printf(“%d”, , *(p+1));return 0;} Powerpoint Templates Page 19
    20. 20. AnswerOutput: 024 Powerpoint Templates Page 20
    21. 21. Categories Easy Medium Hard Powerpoint Templates Page 21
    22. 22. Question Which of the following statement is correct?a. Int a=64<<2;b. Float a =6.42<<2;c. Double a = 3.33<<2;d. Long double a =3.67<<2; Powerpoint Templates Page 22
    23. 23. Answera. Int a=64<<2; Powerpoint Templates Page 23
    24. 24. Categories Easy Medium Hard Powerpoint Templates Page 24
    25. 25. QuestionWould the following program give acompilation error or warning?#include<stdio.h>int main(){int *p1, i=25; a. Yesvoid *p2; b. nop1=&i;p2=&i;p1=p2;p2=p1;return 0; Powerpoint Templates Page 25}
    26. 26. Answer b. NoPowerpoint Templates Page 26
    27. 27. Categories Easy Medium Hard Powerpoint Templates Page 27
    28. 28. Question• In a file contains the line "I am a boyrn" then on reading this line into the array str using fgets(). What will str contain?• A. "I am a boyrn0"• B. "I am a boyr0"• C. "I am a boyn0"• D. "I am a boy" Powerpoint Templates Page 28
    29. 29. AnswerC. "I am a boyn0" Powerpoint Templates Page 29
    30. 30. Categories Easy Medium Hard Powerpoint Templates Page 30
    31. 31. QuestionWhat would be the result of theexpression a^a?a. 0b. 1c. Sum of two operandsd. Multiplication of two operands Powerpoint Templates Page 31
    32. 32. Answera. 0 Powerpoint Templates Page 32
    33. 33. Categories Easy Medium Hard Powerpoint Templates Page 33
    34. 34. QuestionWould the following program givea compilation error or warning?#include<stdio.h>int main(){float *p1,i=25.50; a. Yeschar *p2; b. Nop1=&i;p2=&i;return 0;} Powerpoint Templates Page 34
    35. 35. Answer a. YesPowerpoint Templates Page 35
    36. 36. Categories Easy Medium Hard Powerpoint Templates Page 36
    37. 37. QuestionWrite a program in C to display anymessage without using semi colonanywhere in program? Powerpoint Templates Page 37
    38. 38. Answer#include <stdio.h>void main(){if(printf(”Hello”)){}NOTE: We can write the printf inside while or switch as well for same result. Powerpoint Templates Page 38
    39. 39. Categories Easy Medium Hard Powerpoint Templates Page 39
    40. 40. QuestionWhat will be the output of the code snippet given below:#include<stdio.h>Void main(){Int a =10,b =65;Printf(“%d”,a<<(a&b));}a. 65 c. 0d. 1 b. 10 Powerpoint Templates Page 40
    41. 41. Answer b. 10Powerpoint Templates Page 41
    42. 42. Categories Easy Medium Hard Powerpoint Templates Page 42
    43. 43. QuestionPredict the output:#include<stdio.h> int main() { int a[]={10,20,30,40,50}; int j; for(j=0;j<5;j++) { printf(“%dn”, *a); a++; }return 0; Powerpoint Templates} Page 43
    44. 44. AnswerOutput:Error message: Lvaluerequired in function main Powerpoint Templates Page 44
    45. 45. Categories Easy Medium Hard Powerpoint Templates Page 45
    46. 46. Question#include<stdio.h>int main(){ char str[20] = "Hello"; char *const p=str; *p=M; printf("%sn", str); return 0; Powerpoint Templates} Page 46
    47. 47. Answer MELLOPowerpoint Templates Page 47
    48. 48. Categories Easy Medium Hard Powerpoint Templates Page 48
    49. 49. Question Who were the two main individuals involved in development of K&R standard for C language?a. Dennis Ritchie & John Von Neumannb. Brian Kernighan & Dennis Ritchiec. Grace Hopper & Niklaus Wirthd. Dennis Ritchie & Bjarne Stroustroup Powerpoint Templates Page 49
    50. 50. Answer Brian Kernighan and Dennis Ritchie• Powerpoint Templates Page 50
    51. 51. Categories Easy Medium Hard Powerpoint Templates Page 51
    52. 52. QuestionPredict the output:#include<stdio.h>int main(){float a[]={13.24, 1.5, 1.5, 5.4, 3.5};float *j, *k;j=a;k=a+4;i = j*2;k =k/2;printf(“%f %fn”, *j. *k);return 0; Powerpoint Templates Page 52}
    53. 53. AnswerOutput:Error message: illegal useof pointer in function main Powerpoint Templates Page 53
    54. 54. Categories Easy Medium Hard Powerpoint Templates Page 54
    55. 55. Questionvoid main(){int i=10;static int x=i; if(x==i)printf("Equal");else if(x>i)printf("Greater than");else printf("Less than"); Powerpoint Templates Page 55
    56. 56. AnswerCompiler errorPowerpoint Templates Page 56
    57. 57. Categories Easy Medium Hard Powerpoint Templates Page 57
    58. 58. QuestionWhich of the following utilityis used for compiling andlinking the program?a. Makeb. Makefilec. Compilerd. linker Powerpoint Templates Page 58
    59. 59. Answera. Make Powerpoint Templates Page 59
    60. 60. Categories Easy Medium Hard Powerpoint Templates Page 60
    61. 61. QuestionWould the following program give acompilation error or warning?#include<stdio.h>int main(){char a[]=”sunstroke”; a. Yeschar *p = “coldwave”; b. Noa = “coldwave”;p = “sunstroke”;printf(“%s %sn”, a, p);return 0;} Powerpoint Templates Page 61
    62. 62. Answer b. NoPowerpoint Templates Page 62
    63. 63. Categories Easy Medium Hard Powerpoint Templates Page 63
    64. 64. QuestionWrite a c program to add twonumbers without add operator? Powerpoint Templates Page 64
    65. 65. Answer#include <stdio.h>#include <conio.h>int main(){ int a=1,b=2,c; c=a-(-b); printf(“%d”,c); getch(); return 0; Powerpoint Templates} Page 65
    66. 66. Categories Easy Medium Hard Powerpoint Templates Page 66
    67. 67. QuestionWhich of the followingfunction is used to copy datatypes other than strings fromone variable to another?a. memcpy() c. objcpy()b. datacpy() d. strcpy() Powerpoint Templates Page 67
    68. 68. Answera. memcpy() Powerpoint Templates Page 68
    69. 69. Categories Easy Medium Hard Powerpoint Templates Page 69
    70. 70. QuestionPredict the output:#include<stdio.h>#include<string.h>int main(){char s[]=”rendezvous !”;printf(“%dn”, *(s + strlen (s)));return 0; Powerpoint Templates} Page 70
    71. 71. AnswerOutput: 0 Powerpoint Templates Page 71
    72. 72. Categories Easy Medium Hard Powerpoint Templates Page 72
    73. 73. QuestionWhat will be the output of the code snippet given below?#include<stdio.h>Void main(){Char ch = ‘A’;Printf(“%d”, ch | ‘A’ & ‘Z’);} Powerpoint Templates Page 73
    74. 74. Answer 65Powerpoint Templates Page 74
    75. 75. Categories Easy Medium Hard Powerpoint Templates Page 75
    76. 76. QuestionConsider the following program segment:int a=35;int *b;b= &a;A. b contains address of an intB. value at address contained in b is an int.C. b is a pointer which points in the direction of an int. Powerpoint TemplatesD. all of the above Page 76
    77. 77. Answerd. all of the above Powerpoint Templates Page 77
    78. 78. Categories Easy Medium Hard Powerpoint Templates Page 78
    79. 79. QuestionPredict the output:#include<stdio.h>#include<string.h>int main(){printf(5 + “fascimile”);return 0;} Powerpoint Templates Page 79
    80. 80. AnswerOutput: mile Powerpoint Templates Page 80
    81. 81. Categories Easy Medium Hard Powerpoint Templates Page 81
    82. 82. QuestionPredict the output:#define call(x) #xvoid main(){ printf("%s",call(c/c++));} Powerpoint Templates Page 82
    83. 83. Answer c/c++Powerpoint Templates Page 83
    84. 84. Categories Easy Medium Hard Powerpoint Templates Page 84
    85. 85. QuestionIn which header file is the NULL macro defined?a. <stdio.h>b. <stddef.h>c. # defined. All of the above Powerpoint Templates Page 85
    86. 86. Answerc. All of the above Powerpoint Templates Page 86
    87. 87. Categories Easy Medium Hard Powerpoint Templates Page 87
    88. 88. QuestionPredict the output:#include<stdio.h>int main(){int arr[12];printf(“%dn”, sizeof(arr));return 0;} Powerpoint Templates Page 88
    89. 89. AnswerOutput: 24 Powerpoint Templates Page 89
    90. 90. Categories Easy Medium Hard Powerpoint Templates Page 90
    91. 91. Questionstruct marks{int p:3; int c:3; int m:2;};void main(){struct marks s={2,-6,5};printf("%d %d %d",s.p,s.c,s.m); Powerpoint Templates Page 91
    92. 92. Answer 221 221Powerpoint Templates Page 92
    93. 93. Categories Easy Medium Hard Powerpoint Templates Page 93
    94. 94. QuestionIs the NULL pointer same asan uninitialized pointer ? a. Yes b. No Powerpoint Templates Page 94
    95. 95. Answer b. NoPowerpoint Templates Page 95
    96. 96. Categories Easy Medium Hard Powerpoint Templates Page 96
    97. 97. QuestionWhat is the current versionof standard for c languagewas approved in December2011? Powerpoint Templates Page 97
    98. 98. Answer C11Powerpoint Templates Page 98
    99. 99. Categories Easy Medium Hard Powerpoint Templates Page 99
    100. 100. QuestionPredict the output:void main(){ int a=25; clrscr(); printf("%o %x",a,a); getch();} Powerpoint Templates Page 100
    101. 101. Answer 31 19Powerpoint Templates Page 101
    102. 102. Categories Easy Medium Hard Powerpoint Templates Page 102
    103. 103. QuestionState true or false:Multiplication of a pointerand an unsigned integer isallowed a. True b. false Powerpoint Templates Page 103
    104. 104. Answer b. FalsePowerpoint Templates Page 104
    105. 105. Categories Easy Medium Hard Powerpoint Templates Page 105
    106. 106. Question• In which numbering system can the binary number 1011011111000101 be easily converted to? A. Decimal system B. Hexadecimal system C. Octal system D. No need to convert Powerpoint Templates Page 106
    107. 107. AnswerHexadecimal system Powerpoint Templates Page 107
    108. 108. Categories Easy Medium Hard Powerpoint Templates Page 108
    109. 109. QuestionPredict the output:void main(){ int a=-12; a=a>>3;printf("%d",a);} Powerpoint Templates Page 109
    110. 110. Answer -2Powerpoint Templates Page 110
    111. 111. Categories Easy Medium Hard Powerpoint Templates Page 111
    112. 112. QuestionDoes mentioning the arrayname gives the baseaddress in all the contexts? a. Yes b. no Powerpoint Templates Page 112
    113. 113. Answer b. NoPowerpoint Templates Page 113
    114. 114. Categories Easy Medium Hard Powerpoint Templates Page 114
    115. 115. Question• What is the difference between #include <> and #include “ ” ? Powerpoint Templates Page 115
    116. 116. Answer#include <> ---- > specifically used for built in header file.#include ” ” ----->specifically usedfor user defined/created n headerfiles. Powerpoint Templates Page 116
    117. 117. Categories Easy Medium Hard Powerpoint Templates Page 117
    118. 118. QuestionAssuming, integer is 2 byte, Whatwill be the output of the program? #include<stdio.h> int main() { printf("%xn", -1>>1); return 0; } Powerpoint Templates Page 118
    119. 119. Answer ffffPowerpoint Templates Page 119
    120. 120. Categories Easy Medium Hard Powerpoint Templates Page 120
    121. 121. QuestionA pointer to a block ofmemory is effectivelysame as the array a. True b. False Powerpoint Templates Page 121
    122. 122. Answer a. TruePowerpoint Templates Page 122
    123. 123. Categories Easy Medium Hard Powerpoint Templates Page 123
    124. 124. QuestionFind the ERROR: void main() { int const * p=5; printf("%d",++(*p)); } Powerpoint Templates Page 124
    125. 125. AnswerCompiler error: Cannot modify a constant value. Powerpoint Templates Page 125
    126. 126. Categories Easy Medium Hard Powerpoint Templates Page 126
    127. 127. QuestionPredict the output:#include "string.h"void main(){ clrscr();printf("%d %d",sizeof("string"),strlen("string");getch();} Powerpoint Templates Page 127
    128. 128. Answer 76Powerpoint Templates Page 128
    129. 129. Categories Easy Medium Hard Powerpoint Templates Page 129
    130. 130. Question What does the following declaration mean:a. index of the pointer variableb. memory location as 10c. ptr is a pointer to an array of 10 integersd. none of the above Powerpoint Templates Page 130
    131. 131. Answerc. ptr is a pointer to an array of 10 integers Powerpoint Templates Page 131
    132. 132. Categories Easy Medium Hard Powerpoint Templates Page 132
    133. 133. QuestionTwo different operators wouldalways have differentAssociativity.A. Yes B. No Powerpoint Templates Page 133
    134. 134. Answer NOPowerpoint Templates Page 134
    135. 135. Categories Easy Medium Hard Powerpoint Templates Page 135
    136. 136. QuestionPredict the output:#include<stdio.h>void main(){int i;For(i=0;i++<10;)Printf(“%dn”,i);} Powerpoint Templates Page 136
    137. 137. Answer 2 3 4 5 6 7 8 9 10Powerpoint Templates Page 137
    138. 138. Categories Easy Medium Hard Powerpoint Templates Page 138
    139. 139. QuestionPredict the output:#include<stdio.h>int main(){printf(“%c”, “abcdefgh”[4]);return 0;} Powerpoint Templates Page 139
    140. 140. Answer 0Powerpoint Templates Page 140
    141. 141. Categories Easy Medium Hard Powerpoint Templates Page 141
    142. 142. Question• Data written into a file using fwrite() can be read back using fscanf() A. True B. False Powerpoint Templates Page 142
    143. 143. Answer FALSEPowerpoint Templates Page 143
    144. 144. Categories Easy Medium Hard Powerpoint Templates Page 144
    145. 145. QuestionWhat the following code will display?void main(){ printf("%s",__DATE__);} Powerpoint Templates Page 145
    146. 146. AnswerCurrent system DATE Powerpoint Templates Page 146
    147. 147. Categories Easy Medium Hard Powerpoint Templates Page 147
    148. 148. QuestionPredict the output:#include<stdio.h>int main(){char str[7] = “strings”;printf(“%sn” , str);return 0;} Powerpoint Templates Page 148
    149. 149. AnswerOutput: cannot predict Powerpoint Templates Page 149
    150. 150. Categories Easy Medium Hard Powerpoint Templates Page 150
    151. 151. QuestionWhat do the functions atoi()?A. is a macro that converts integer to character.B. It converts an integer to stringC. It converts a floating point number to string Powerpoint Templates Page 151
    152. 152. Answeris a macro that converts integer to character Powerpoint Templates Page 152
    153. 153. Categories Easy Medium Hard Powerpoint Templates Page 153
    154. 154. QuestionPredict the output:void main(){ printf("%s","c" "question" "bank");}A. c question bankB. bankC. cquestionbankD. Compiler error Powerpoint Templates Page 154
    155. 155. AnswercquestionbankPowerpoint Templates Page 155
    156. 156. Categories Easy Medium Hard Powerpoint Templates Page 156
    157. 157. QuestionWould the following code compile successfully?# include<stdio.h>int main(){printf(“%c”, 7[“sundaram”]);return 0;} Powerpoint Templates Page 157
    158. 158. AnswerAns: YesPowerpoint Templates Page 158
    159. 159. Categories Easy Medium Hard Powerpoint Templates Page 159
    160. 160. QuestionGive the output:main() { #define a 50 printf("%d",a); } Powerpoint Templates Page 160
    161. 161. Answer 50Powerpoint Templates Page 161
    162. 162. Categories Easy Medium Hard Powerpoint Templates Page 162
    163. 163. QuestionGive the output:void main(){ char *str="c-pointer"; printf("%*.*s",10,7,str);}(a. c-pointer b. c-pointer c. c-point Powerpoint Templates Page 163 d. cpointer null null
    164. 164. Answer c-pointPowerpoint Templates Page 164
    165. 165. Categories Easy Medium Hard Powerpoint Templates Page 165
    166. 166. QuestionWhich of the following statements are correct about the program?#include<stdio.h> int main() { printf("%pn", main()); return 0; } Powerpoint Templates Page 166
    167. 167. AnswerIt prints garbage values infinitely Powerpoint Templates Page 167
    168. 168. Categories Easy Medium Hard Powerpoint Templates Page 168
    169. 169. Question• Find the error:typedef struct{int data;NODEPTR link;}*NODEPTR; Powerpoint Templates Page 169
    170. 170. AnswerError: typedef cannot be used until is define Powerpoint Templates Page 170
    171. 171. Categories Easy Medium Hard Powerpoint Templates Page 171
    172. 172. Question• Predict the output:#include<stdio.h>void main(){int i;For(i=0;++i<=10;)Printf(“%dn”,i);} Powerpoint Templates Page 172
    173. 173. Answer 1 2 3 4 5 6 7 8 9Powerpoint Templates Page 173
    174. 174. Categories Easy Medium Hard Powerpoint Templates Page 174
    175. 175. QuestionPredict the output:#include<stdio.h>#include<string.h>Int main{Char str1[]=“learn through IndiaBIX0.com”, str2[120];Char *p;P=(char*)memccpy(str2,str1,’I’,strlen(str1));*p=‘0’;Printf(“%s”,str2); Powerpoint TemplatesReturn 0; Page 175
    176. 176. Answer“learn through indi” Powerpoint Templates Page 176
    177. 177. Categories Easy Medium Hard Powerpoint Templates Page 177
    178. 178. QuestionState true or false:• In place of the condition in a while loop structure there can be any other valid expression Powerpoint Templates Page 178
    179. 179. Answer TruePowerpoint Templates Page 179
    180. 180. Categories Easy Medium Hard Powerpoint Templates Page 180
    181. 181. QuestionPredict the output:#include<stdio.h>Void main(){Char arr[7]=“NETWORK”;Printf(“%s”,arr);} Powerpoint Templates Page 181
    182. 182. AnswerGarbage value Powerpoint Templates Page 182
    183. 183. Categories Easy Medium Hard Powerpoint Templates Page 183
    184. 184. Question START Initialize False Test True Body of loop Stop increement Powerpoint Templates• What does the above flowchart shows?184 Page
    185. 185. AnswerShows the flowchart of FOR LOOP Powerpoint Templates Page 185
    186. 186. Categories Easy Medium Hard Powerpoint Templates Page 186

    ×