Welcome to C Programming Quiz, Randomly Selected !!

Question 1. 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 2. what will be the output of the following program?
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);

12,10,11,13

22,10,11,13

12,11,11,11

Undefined Behavior

Question 3. Which of the following function is correct that finds the length of a string?

int xstrlen(char *s) { int length=0; while(*s!='\0') { length++; s++; } return (length); }

int xstrlen(char s) { int length=0; while(*s!='\0') length++; s++; return (length); }

int xstrlen(char *s) { int length=0; while(*s!='\0') length++; return (length); }

int xstrlen(char *s) { int length=0; while(*s!='\0') s++; return (length); }

Question 4. What will be the output of the program?
int main(void) {

                int i=3, j;
                i++ + i++ + i++;
                printf("%d", j);
                return 0;
}

9

15

compilation error

undefined behavior

Question 5. What function should be used to free the memory allocated by calloc() ?

dealloc();

demalloc(variable_name, 0)

free()

decalloc(variable_name, 0)

Question 6. what is the value of x when the following sample code is executed
int x = 3; 
if( x == 2 );
  x = 0; 
if( x == 3 )
 x++; 
else x += 2;

4

2

4

0

Question 7. what is the output of the following sample code?
void myFunc (int x) 
{ 
   if (x > 0)
   myFunc(--x); 
   printf("%d, ", x); 
} 
int main() 
{ 
   myFunc(5); 
   return 0; 
}

1, 2, 3, 4, 5, 5,

4, 3, 2, 1, 0, 0,

0, 0, 1, 2, 3, 4,

0, 1, 2, 3, 4, 5,

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. 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 10. what is meant by (void*)0

representation of void pointer

representation of null pointer

both of the above

Compilation Error