Skip to content

Category Archives: C Quiz

Pick the best statement for the following program snippet: #include "stdio.h" void foo(void) {  static int staticVar;  staticVar++;  printf("foo: %d\n",staticVar); }    void bar(void) {… Read More
Pick the best statement for the following program snippet: #include <stdio.h>    int main() {  int var;  /*Suppose address of var is 2000 */   … Read More
In C, 1D array of int can be defined as follows and both are correct. int array1D[4] = {1,2,3,4}; int array1D[] = {1,2,3,4}; But given… Read More
The below program would give compile error because comma has been used after foo(). Instead, semi-colon should be used i.e. the way it has been… Read More
Typically, library header files in C (e.g. stdio.h) contain not only declaration of functions and macro definitions but they contain definition of user defined data… Read More
The following program won’t compile because there’re space between macro name and open parenthesis. #include "stdio.h"    #define MYINC   (  a  )  (  ( a… Read More
Suppose someone writes increment macro (i.e. which increments the value by one) in following ways: #define INC1(a) ((a)+1)    #define INC2 (a) ((a)+1)    #define… Read More
Find out the correct statement for the following program. #include "stdio.h"    int * arrPtr[5];    int main() {  if(*(arrPtr+2) == *(arrPtr+4))  {    printf("Equal!");  }… Read More
Find out the correct statement for the following program. #include "stdio.h"    int * gPtr;    int main() {  int * lPtr = NULL;   … Read More
Find out the correct statement for the following program. #include "stdio.h"    typedef int (*funPtr)(int);    int inc(int a) {  printf("Inside inc() %d\n",a);  return (a+1);… Read More
Pick the best statement for the following program. #include "stdio.h"    int foo(int a) {  printf("%d",a);  return 0; }    int main() {  foo;  return… Read More
In the following program snippet, both s1 and s2 would be variables of structure type defined as below and there won’t be any compilation issue.… Read More
In a C file (say sourcefile1.c), an array is defined as follows. Here, we don’t need to mention array arr size explicitly in [] because… Read More
Both of the following declarations for function pointers are equivalent. Second one (i.e. with typedef) looks cleaner. /* First Declaration */ int (*funPtr1)(int), (*funPtr2)(int);   … Read More
Anyone of the following can be used to declare a node for a singly linked list and “NODEPTR nodePtr;” can be used to declare pointer… Read More

Start Your Coding Journey Now!