Welcome to C Programming Quiz, Intermediate Level !!

Question 1. 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 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 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 4. What will the function rewind() do?

Reposition the file pointer to a character reverse.

Reposition the file pointer stream to end of file.

Reposition the file pointer to begining of that line.

Reposition the file pointer to begining of file.

Question 5. What will be the output of the program?
#include<stdio.h>
#include<stdlib.h>

union employee
{
    char name[15];
    int age;
    float salary;
};
const union employee e1;

int main()
{
    strcpy(e1.name, "K");
    printf("%s %d %f", e1.name, e1.age, e1.salary);
    return 0;
}

Error: RValue required

Error: cannot convert from 'const int *' to 'int *const'

Error: LValue required in strcpy

no error

Question 6. 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 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. What does the following declaration mean?
int (*ptr)[10]

ptr is array of pointers to 10 integers

ptr is a pointer to an array of 10 integers

ptr is an array of 10 integers

ptr is an pointer to array

Question 9. 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 10. 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