C Language

Quizzes and Questions about ANSI C language.

static storage class keyword

Multiple choice question

What is the 'static' keyword used for?

volatile storage class keyword

Multiple choice question

What is the 'volatile' keyword used for?

register storage class keyword

Multiple choice question

What is the 'register' keyword used for?

auto storage class keyword

Multiple choice question

What is the auto keyword used for?

declaration of function without parameters

Multiple choice question

Are the following two C function prototypes the same?

int func(void);
int func();

Left side increment sent as Macro actual parameter

Multiple choice question

What will be the output of the following C language program?

#include <stdio.h>
#define MAX(A,B) (A)>(B)?(A):(B)

void main() {
   int a=3,b=5;
   printf(“The maximum is %d\n”, MAX(a,++b));
}

Swap elements at Macro

Multiple choice question

What will be the output of the following C program?

#include <stdio.h>
#define SWAP (T,A,B) {\
T temp;\
temp = A;\
A = B;\
B= temp;\
}

int main()
{
  int arr[] = { 3,4,5,6,7,8,9);
  int j;
  int i=2;

  SWAP(int, i , arr[i])
  for(j=0;j<7;j++)
   printf(“%d “, arr[j]);
  return 0;
}

Missing parentheses arount the Macro formal parameters

Multiple choice question

What will be the output of the following program?

#include <stdio.h>
#define SQUARE(x) x*x
int main()
{
  int res;

  res = SQUARE(2+1);
  printf("%d\n", res);
  return 0;
}

Right side increment in Macro

Multiple choice question

What will be the output of the following program?

#include <stdio.h>
#define MAX(A,B) ((A) > (B) ? (A) : (B))

int main(){
  int i=4;
  int j=5;
  int x;

  x = MAX(i++, j++);
  printf("%d %d %d \n", i, j, x);
  return 0;
}

Is it allowed in C to have a recursive include directive

Multiple choice question

Is it allowed in C to have a recursive #include directive

Syndicate content