Welcome to C Programming Quiz, Intermediate Level !!

Question 1. 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 2. what is the output of the following program?
char* myFunc (char *ptr)
{
 ptr  += 3;
 return (ptr);
} 
int main()
{
 char *x, *y;
 x = "HELLO";
 y = myFunc (x);
 printf ("y = %s \n", y);
 return 0;
}

y = HELLO

y = ELLO

y = LLO

y = LO

Question 3. 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 4. In the following code, the P2 is Integer Pointer or Integer?
typedef int *ptr;
ptr p1, p2;

integer

integer pointer

error in declaration

none of the above

Question 5. char txt [20] = "Hello world!\0";
How many bytes are allocated by the definition above?

11 bytes

12 bytes

13 bytes

20 bytes

Question 6. 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 7. 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 8. Assuming a short is two bytes long, what will be printed by the following code sample?
 short testarray[4][3] = { {1}, {2, 3}, {4, 5, 6} }; 
 printf( "%d\n", sizeof( testarray ) );

It will not compile because not enough initializers are given.

6

12

24

Question 9. How many times "TechInfoGurus" is get printed?
#include<stdio.h>
int main()
{
    int x;
    for(x=-1; x<=10; x++)
    {
        if(x < 5)
            continue;
        else
            break;
        printf("TechInfoGurus");
    }
    return 0;
}

infinite number of times

11

0

10

Question 10. We want to round off x, a float, to an int value, The correct way to do is

y = (int)(x + 0.5)

y = int(x + 0.5)

y = (int)x + 0.5

y = (int)((int)x + 0.5)