C interview questions

C interview questions for beginners

What is the output of the following code?

#include<stdio.h>
 int main() {
   int i;
   for (i = 0; i < 5; i++) {
     static int a = 0;
     int b = 0;
     a++;
     b++;
     printf("\na=%d", a);
     printf(",b=%d", b);
   }
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
  extern int a;
  int main() {
    printf("\na=%d", a);
    return 0;
  }

What is the output of the following code?

#include<stdio.h>
 extern int a;
 int main() {
     printf("\n a = %d", a);
     return 0;
 }
 int a;

What is the output of the following code?

#include<stdio.h>
extern int a = 5;
int main() {
  printf("\n a = %d", a);
  return 0;
}
int a;

What is the output of the following code?

#include<stdio.h>
void fun(int _) {
    printf("%d", _);
}
int main() {
  fun(23);
  return 0;
}

What is the output of the following code?

 #include<stdio.h>
  void fun(auto int a) {
    printf("%d", a);
  }
int main() {
  fun(23);
  return 0;
}

What is the output of the following code?

 #include<stdio.h>
  void fun(register int a) {
    printf("%d", a);
  }
int main() {
  fun(23);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
 int main() {
   auto a;
   register r;
   static s;
   extern e;
   typedef t;
   printf("\n%d", sizeof a);
   printf("\n%d", sizeof r);
   printf("\n%d", sizeof s);
   printf("\n%d", sizeof e);
   printf("\n%d", sizeof(t));
   return 0;
 }

C interview questions for freshers

What is the output of the following code?

#include<stdio.h>
 int main() {
   auto a;
   register r;
   static s;
   extern e;
   typedef t;
   printf("\n%d", sizeof a);
   printf("\n%d", sizeof r);
   printf("\n%d", sizeof s);
   printf("\n%d", sizeof e);
   printf("\n%d", sizeof t);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
static extern int a = 5;
static int b = 6;
int main() {
  printf("\n%d", a);
  printf("\n%d", b);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
 void main() {
   float f;
   clrscr();
   f = balututorial(33);
   printf("%f", f);
   getch();
 }
float balututorial(int x) {
  float r = (float) x;
  return r;
}

What is the output of the following code?

 #include<stdio.h>
  void main() {
    static int a = 25;
    void cdecl conv1();
    void pascal conv2();
    call1(a);
    call2(a);
    getch();
  }
void cdecl call1(int a, int b) {
  printf("%d %d", a, b);

}
void pascal call2(int a, int b) {
  printf("\n%d %d", a, b);
}

What is the output of the following code?

 #include<stdio.h>
  void cdecl fun1(int, int);
  void pascal fun2(int, int);
  int main() {
    int a = 5, b = 5;
    fun1(++a, a++);
    fun2(b++, ++b);
    return 0;
}
void cdecl fun1(int p, int q) {
  printf("cdecl:  %d %d \n", p, q);
}
void pascal fun2(int p, int q) {
  printf("pascal: %d %d", p, q);
}

What is the output of the following code?

 #include <stdio.h>
 void convention(int, int, int);
 int main() {
   int a = 5;
   convention(a, ++a, a++);
   return 0;
 }
void convention(int p, int q, int r) {
  printf("%d %d %d", p, q, r);
}

What is the output of the following code?

  #include <stdio.h>
  int balututorial(register int, register int);
  int main() {
  int temp;
  temp = balututorial(5, 25);
  printf("%d", temp);
  return 0;
}
int balututorial(int register x, int register y) {
  static int num;
  num = ~x + y + 1;
  return num;
}

fresher c interview questions

What is the output of the following code?

  #include <stdio.h>
  int main() {
    funcall(2);
    return 0;
  }
int funcall(long int p, long int q, long int r) {
  printf("%d %d %d", p, q, r);
  return 0;
}

What is the output of the following code?

  #include <stdio.h>
  void funcall(float, float, float);
  int main() {
    funcall(5.0 f);
    return 0;
}
void funcall(float x, float y, float z) {
  printf("%f %f %f", x, y, z);
}

What is the output of the following code?

  #include <stdio.h>
  int main() {
    funcall('A');
    return 0;
  }
int funcall(char x, char y, char z) {
  printf("%c %c %c", x, y, z);
  return 0;
}

What is the output of the following code?

 #include<stdio.h>
  int test();
int main() {
  for (test(); test(); test()) {
    printf("%d ", test());
  }
  return 0;
}
int test() {
  int static num = 7;
  return num--;
}

What is the output of the following code?

#include<stdio.h>
  int main() {
    register a, b, sum;
    scanf(ā€œ % d % dā€, & a, & b);
    sum = a + b;
    printf(ā€œ % dā€, sum);
    return 0;
  }

What is the output of the following code?

#include<stdio.h>
  int balututorial(int, ...);
  int main() {
  int x, y;
  x = balututorial(2, 4, 6, 8, 10, 12, 14);
  y = balututorial(3, 6, 9, 12);
  printf("%d %d ", x, y);
  return 0;
}
int balututorial(int s, ...) {
  void * ptr;
  ptr = ...;
  (int*) ptr += 2;
  s = *(int*)ptr;
  return s;
}

C function interview questions

What is the output of the following code?

 #include<stdio.h>
  int main() {
    int x, num = 1;
    x = call(num);
    printf("%d", x);
    return 0;
  }
int call(int num) {
  static int x = 0;
  if (num < 4) {
    x = x + num;
    call(num + 1);
  } else
    break;
  return x;
}

What is the output of the following code?

#include <stdio.h>
int* function();
int main() {
  auto int* x;
  int *(*ptr)();
  ptr = &function;
  x = (*ptr)();
  printf("%d", *x);
  return 0;
}
int* function() {
  static int a = 10;
  return &a;
}

What is the output of the following code?

 #include <stdio.h>
 int find(char);
 int(*function ())(char);
 int main() {
  int x;
  int(*ptr)(char);
  ptr=function ();
  x = (*ptr)('A');
  printf("%d", x);
  return 0;
}
int find(char c) {
  return c;
}
int(*function())(char) {
  return find;
}

Leave a Reply

Your email address will not be published. Required fields are marked *