c interview questions

This article covers all the  c interview questions on the data types and operator on various patter for a fresher interview in MNC’s

What is the output of the following code?

#include<stdio.h
 int main() {
   printf(" %d %d", sizeof(char), sizeof(unsigned char)); 
   printf("\n %d %d %d", sizeof(int), sizeof(unsigned int), sizeof(long)); 
   printf("\n %d %d %d", sizeof(float), sizeof(double), sizeof(long double)); 
   printf("\n %d %d", sizeof(signed), sizeof(unsigned));
   return 0;
  }

What is the output of the following code?

#include<stdio.h>
int main() {
  printf(" %d", sizeof(‘A’));
  printf("\n %d %d %d %d", sizeof(25), sizeof(25l), sizeof(25u), sizeof(25lu));
  printf("\n %d %d %d", sizeof(25.5), sizeof(25.5f), sizeof(25.5lf));
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  char a, b;
  a = 'A';
  b = 'B';
  printf("\n %d %d", a, b);
  printf("\n %d %d", 'a', 'b');
  printf("\n % c % c", a, b);
  printf("\n % c % c", a + 32, b + 32);
  printf("\n %d %d", a + 32, b + 32);
  printf("\n % c % c", 'a' - 32, 'b' - 32);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  int i;
  long l;
  float f;
  i = 32767 + 1;
  l = 32767 + 1;
  f = 32767 + 1;
  printf(" %d % ld % f", i, l, f);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
 int main() {
   int i;
   long l;
   float f;
   i = 32767 + 1;
   l = 32767 l + 1;
   f = 32767.0 f + 1;
   printf(" %d % ld % f", i, l, f);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
 int main() {
   int i;
   long l;
   float f;
   i = 32767 + 1;
   l = (long) 32767 + 1;
   f = (float) 32767 + 1;
   printf(" %d %d %d", i, l, f);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
int main() {
  printf("Hello\ nBalu");
  printf("Welcome\\\\nBalututorial.com");
  printf("Welcome\\\\\nBalututorial.com");
  printf("Welcome\b\b");
  printf("Welcome\b\bHello");
  printf("Hello\r");
  printf("Welcome\rHello");
  printf("Hello\tWelcome");
  printf("\n %c %c %c %c", (char)65, (char)97, (char)48, (char)59);
  printf(" %c %c", (char)10, (char)32);
  printf("\n %d %d", (int)'\n', (int)'\0');
  return 0;
}

What is the output of the following code?

#include<stdio.h>
 int main() {
   printf("\n%d,%d,%d,%d", printf("\na"), printf("\nab"), printf("\nabc"), printf("\nabcd"));
   return 0;
 }

c interview questions for fresher

What is the output of the following code?

#include<stdio.h>
 int main() {
   printf(" %d % o % x", 100, 100, 100);
   printf("\n %d % o % x", 0234, 0234, 0234);
   printf("\n %d % o % x", 0xAE, 0XAE, 0XAE);
   printf("\n % i % o % p", 064, 064, 064);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
int main() {
  printf("\n%u", sizeof 0x23);
  printf("\n%u", sizeof 023);
  printf("\n%u", sizeof 23);
  printf("\n%u", sizeof 0x23 L);
  printf("\n % u", sizeof 023 L);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  char ch = '{';
  printf("\n%u", sizeof '{');
  printf("\n%u", sizeof ch);
  printf("\n%u", sizeof(char));
  return 0;
}

What is the output of the following code?

#include <stdio.h>
int main() {
int a = 256, b = -1;
int c;
c = a & b;
printf("\n%d", c);
return 0;
}

What is the output of the following code?

  #include <stdio.h>
  int main() {
  int a = 256, b = -1;
  int c;
  c = a | b;
  printf("\n%d", c);
  return 0;
}

What is the output of the following code?

#include <stdio.h>
 int main() {
   int a = 256, b = -1;
   int c;
   c = a ^ b;
   printf("\n%d", c);
   return 0;
 }

What is the output of the following code?

#include <stdio.h>
 int main() {
   int a, b, c;
   a = 4 << 1;
   a = 4 << 2;
   a = 4 << 3;
   printf("\n%d", a);
   printf("\n%d", b);
   printf("\n%d", c);
   return 0;
 }

What is the output of the following code?

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

fresher c interview questions

What is the output of the following code?

#include <stdio.h>
int main() {
  int a = 255;
  int b;
  int c;
  int d;
  int e;
  b = !a;
  c = !!a;
  d = ~a;
  e = ~~a;
  printf("\n%d", b);
  printf("\n%d", c);
  printf("\n%d", d);
  printf("\n%d", e);
  return 0;
}

What is the output of the following code?

#include <stdio.h>
int main() {
  float a, b;
  a = 1.7 f;
  b = ~a;
  printf("\n%f", a);
  return 0;
}

What is the output of the following code?

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

What is the output of the following code?

#include<stdio.h>
 int main() {
   int x = -1, y = 32767, z;
   z = x & y;
   printf("z=%d", z);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
 int main() {
   int x = 65535, y = 0, z;
   z = x | y;
   printf("z=%d", z);
   return 0;
 }

What is the output of the following code?

#include<stdio.h>
int main() {
  int x = 255, y = -1, z;
  z = x ^ y;
  printf("z=%d", z);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  int x = 1, i;
  for (i = 0; i <= 16; i++)
    printf("\n%u", x << i);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  int x = -32768;
  printf("\n%u", x >> 1);
  printf("\n%u", x >> 2);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  int x = 16384;
  printf("\n%u", x >> 1);
  printf("\n%u", x >> 2);
  return 0;
}

What is the output of the following code?

#include<stdio.h>
int main() {
  int x = 16384, i;
  for (i = 0; i < 16; i++)
    printf("\n%u", x >> i);
  return 0;
}

What is the output of the following code?

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

What is the output of the following code?

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

Leave a Reply

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