• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

C Quiz - 106

Question 1

What’s the meaning of following declaration in C language? C
int (*p)[5];
  • It will result in compile error because there shouldn\'t be any parenthesis i.e. “int *p[5]” is valid.
  • p is a pointer to 5 integers.
  • p is a pointer to integer array.
  • p is an array of 5 pointers to integers.
  • p is a pointer to an array of 5 integers

Question 2

In a C program, following variables are defined: C
 float      x = 2.17;
 double   y = 2.17;
 long double z = 2.17;
Which of the following is correct way for printing these variables via printf.
  • printf("%f %lf %Lf",x,y,z);
  • printf(“%f %f %f”,x,y,z);
  • printf("%f %ff %fff",x,y,z);
  • printf("%f %lf %llf",x,y,z);

Question 3

“typedef” in C basically works as an alias. Which of the following is correct for “typedef”?
  • typedef can be used to alias compound data types such as struct and union.
  • typedef can be used to alias both compound data types and pointer to these compound types.
  • typedef can be used to alias a function pointer.
  • typedef can be used to alias an array.
  • All of the above.

Question 4

For the following “typedef” in C, pick the best statement C
typedef int INT, *INTPTR, ONEDARR[10], TWODARR[10][10];
  • It will cause compile error because typedef is being used to define multiple aliases of incompatible types in the same statement.
  • “INT x” would define x of type int. Remaining part of the statement would be ignored.
  • “INT x” would define x of type int and “INTPTR y” would define pointer y of type int *. Remaining part of the statement would be ignored.
  • “INT x” would define x of type int. “INTPTR y” would define pointer y of type int *. ONEDARR is an array of 10 int. TWODARR is a 2D array of 10 by 10 int.
  • “INT x” would define x of type int. “INTPTR *y” would define pointer y of type int **. “ONEDARR z” would define z as array of 10 int. “TWODARR t” would define t as array of 10 by 10 int.

Question 5

Assuming int size is 4 bytes, what is going to happen when we compile and run the following program? 
 

C
#include “stdio.h”
int main()
{
  printf(GeeksQuiz\\n);
  main();
  return 0;
}
  • We can’t use main() inside main() and compiler will catch it by showing compiler error.
     

  • GeeksQuiz would be printed in 2147483647 times i.e. (2 to the power 31) - 1.
     

  • It’ll print GeeksQuiz infinite times i.e. the program will continue to run forever until it’s terminated by other means such as CTRL+C or CTRL+Z etc.
     

  • GeeksQuiz would be printed only once. Because when main() is used inside main(), it’s ignored by compiler at run time. This is to make sure that main() is called only once.
     

  • GeeksQuiz would be printed until stack overflow happens for this program.
     

There are 5 questions to complete.

Last Updated :
Take a part in the ongoing discussion