Welcome to C Programming Quiz, Intermediate Level !!

Question 1. 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 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. 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 4. 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 5. 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 6. char txt [20] = "Hello world!\0";
How many bytes are allocated by the definition above?

11 bytes

12 bytes

13 bytes

20 bytes

Question 7. what will be output of the following code sample
int x = 0; 
for ( ; ; ) 
{ 
 if (x++   == 4)
  break; 
 continue; 
} 
printf("x=%d\n", x);

x=0

x=1

x=5

x=4

Question 8. 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 9. Which of the following is the correct order if calling functions in the below code?
a = f1(23, 14) * f2(12/4) + f3();

f1, f2, f3

f3, f2, f1

Order may vary from compiler to compiler

none of the above

Question 10. which one of the following declares "A pointer to an array of three chars"?

char *ptr[3]();

char (*ptr)*[3];

char (*ptr[3])();

char (*ptr)[3];