Welcome to C Programming Quiz, Intermediate Level !!

Question 1. Which one of the following declares - "A pointer to a function which receives an int pointer and returns float pointer"

float *(ptr)*int;

float *(*ptr)(int)

float *(*ptr)(int*)

float (*ptr)(int)

Question 2. what will be the value of "counter" after the following code is executed?
x = 3, counter = 0; 
while ((x-1)) 
{ 
   ++counter; 
   x--; 
}

0

1

2

3

Question 3. What does x mean in this code sample ?
typedef char (*(*arrfptr[3])())[10];
arrfptr x;

x is a pointer

x is an array of three pointer

x is an array of three function pointers

error in declaration of x

Question 4. What would be the equivalent pointer expression for referring the array element a[i][j][k][l]

((((a+i)+j)+k)+l)

*(*(*(*(a+i)+j)+k)+l)

(((a+i)+j)+k+l)

((a+i)+j+k+l)

Question 5. what is the output of the following program?
int y[4] = {6, 7, 8, 9}; 
int *ptr = y  + 2; 
printf("%d\n", ptr[ 1 ] );

Segmentation Fault

7

8

9

Question 6. How many times the program will print "TechInfoGurus" ?
#include<stdio.h>

int main()
{
    printf("TechInfoGurus");
    main();
    return 0;
}

infinite number of times

ERROR : main() cant be called recursively

65535 times

Till stack doesn't overflow

Question 7. Can you combine the following two statements into one?
char *p;
p = (char*) malloc(100);

char p = *malloc(100);

char *p = (char) malloc(100);

char *p = (char*)malloc(100);

char *p = (char *)(malloc*)(100);

Question 8. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample code above contain?

3

11

7

9

Question 9. what is the output of the following code sample?
int x = 0; 
for (x=1; x<4; x++); 
printf("x=%d\n", x);

x=0

x=4

x=5

no output, it will loop forever

Question 10. struct customer *ptr = malloc( sizeof( struct customer ) );
Given the sample allocation for the pointer "ptr" found above, which one of the following statements is used to reallocate ptr to be an array of 10 elements?

ptr = realloc( ptr, 10 * sizeof( struct customer));

realloc( ptr, 9 * sizeof( struct customer ) );

ptr = malloc( 9 * sizeof( struct customer ) );

ptr = realloc( ptr, 9 * sizeof( struct customer ) );