Quiz Questions
Each question has four choices. More than one options can be correct. When you have finished the quiz, click the button at the end of the questions to view the result, and the solutions and answers.
Correct Answers: | |
Wrong Answers: | |
Unattempted: |
Question 1
int main () { int x = -2; for (;x;printf ("%d\n", x++)); return 0; }
-1
2
1
0
Ans: A
x;which will be false when x++ of the printf reaches 0.
Question 2
int main() { int i = 0; int k = ++i; printf ("%d", k); }
Ans: A
Question 3
int main() { char *str = "Hello world"; printf("%d", printf("%s",str)); return 0; }
Ans: C
Question 4
{ static int a[ ] = {0,1,2,3,4}; int *p[ ] = {a,a+1,a+2,a+3,a+4}; int **ptr = p; ptr++; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); *ptr++; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); *++ptr; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); ++*ptr; printf("\n %d %d %d", ptr-p, *ptr-a, **ptr); }
222
333
344
Ans: D
Question 5
int main() { float i = 0; switch (i) { default: case 1: case 0: break; } return 0; }
Ans: D
Question 6
void main() { char s[]={'a','b','c','\n','c','\0'}; char *p,*str,*str1; p=&s[3]; str=p; str1=s; printf("%d",++*p + ++*str1-32); }
Ans: D
++*p. "p is pointing to '\n'and that is incremented by one." the ASCII value of '\n' is 10, which is then incrementedto 11. The value of ++*p is 11.
++*str1, str1 is pointing to 'a' that is incremented by 1and it becomes 'b'. ASCII value of 'b' is 98.Now performing (11 + 98 - 32), we get 77("M");So we get the output 77 :: "M" (Ascii is 77).
Question 7
int main() { int b; int a; /*Statement 1*/ b = 10; { /*Statement 2*/ int x = 0; { /*Statement 3*/ int x = 0; } /*Statement 4*/ a = x; } return 0; }
Ans: A
Question 8
int PlusOne (int); int main() { PlusOne (PlusOne (4)); return 0; } int PlusOne (int i) { return i + 1; }What happens when you run it ? [More than one can be correct]
Ans: CD
Question 9
int main() { char *str=NULL; strcpy(str,"cquestionbank"); printf("%s",str); return 0; }
Ans: D
Question 10
void main() { int i, j; printf("%d",scanf("%d-%d",&i, &j)); // value 10-10 is given as input here }
Ans: C
My C/C++ Videos on Youtube
Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.