C Programming Fundamentals

Test your knowledge of C programming concepts including pointers, arrays, memory allocation, and control structures

12 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

void main() { int a=10,b=20; char x=1,y=0; if(a,b,x,y) { printf("EXAM"); } }

  1. XAM is printed
  2. exam is printed
  3. Compiler Error
  4. Nothing is printed
Question 2 Multiple Choice (Single Answer)

What is the result of 16>>2? 1) 4 2) 8 3) 3 4) 0

  1. 4
  2. 8
  3. 3
  4. 0
Question 3 Multiple Choice (Single Answer)

What is the output of the following code? #include<stdio.h>void main(){char letter =Z;printf("\n%c",letter);}

  1. Z
  2. 90
  3. Error
  4. Garbage Value
Question 4 Multiple Choice (Single Answer)

What is the output of the following code? #include<stdio.h>void main(){ int s=0; while(s++<10) { if(s<4 && s<9) continue; printf("\n%d\t",s); }}

  1. 1 2 3 4 5 6 7 8 9
  2. 1 2 3 10
  3. 4 5 6 7 8 9 10
  4. 4 5 6 7 8 9
Question 5 Multiple Choice (Single Answer)

What is the output of the following code? # include<stdio.h># define a 10 main() { printf("%d..",a); foo(); printf("%d",a); } void foo() { #undef a #define a 50 }

  1. 10..10
  2. 10..50
  3. Error
  4. 0
Question 6 Multiple Choice (Single Answer)

Array passed as an argument to a function is interpreted as

  1. Address of the array
  2. Values of the first elements of the array
  3. Address of the first element of the array
  4. Number of element of the array
Question 7 Multiple Choice (Single Answer)

How can I dynamically allocate a two-dimensional array?

  1. int **array1 = (int **)malloc(nrows * sizeof(int *));
  2. int **array2 = (int **)malloc(nrows * sizeof(int *));
  3. int *array3 = (int *)malloc(nrows * ncolumns * sizeof(int));
  4. Any of the above.
Question 8 Multiple Choice (Single Answer)

main() { char thought[2][30]={"Don`t walk in front of me..","I am not follow"}; printf("%c%c",(thought[0]+9),(*(thought+0)+5)); } What is the output of this program?

  1. k k
  2. Don`t walk in front of me
  3. I may not follow
  4. K
Question 9 Multiple Choice (Single Answer)

#include <stdio.h>void main() { int I=3,*j,**k; j=&I; k=&j; printf("%d%d%d",*j,*k,(*k)); } What is the output of the above program code?

  1. 444
  2. 000
  3. 333
  4. 433
Question 10 Multiple Choice (Single Answer)

Which of the following is the correct way of declaring a float pointer:

  1. float ptr;
  2. float *ptr;
  3. *float ptr;
  4. None of the above
Question 11 Multiple Choice (Single Answer)

The five items: A, B, C, D and E are pushed in a stack,one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is.

  1. A
  2. B
  3. C
  4. D
Question 12 Multiple Choice (Single Answer)

What is the output of the following code? #include<stdio.h> void main() { int a=0,b=0; a = (b = 75) + 9; printf("\n%d, %d",a, b); }

  1. 75, 9
  2. 75, 84
  3. 84, 75
  4. None of these options