c interview questions

An array is a data structure consisting of a collection of elements and each element can be accessed index. A selection of array coding interview questions and answers. Ace your coding interview with these questions from top companies.

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char arr[7] = "Balututorial.com";
    printf("%s", arr);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char arr[11] = "balututorial";
   printf("%s", arr);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char arr[20] = "balututorial";
   printf("%d", sizeof(arr));
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int
    const SIZE = 5;
    int expr;
    double array[SIZE] = {2.0, 4.0,6.0, 8.0,10.0};
    expr = 1 | 2 | 3 | 4;
    printf("%f", array[expr]);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char data[2][3][2] = { 0,1,2,3,4,5,6,7,8,9,10,11};
   printf("%o", data[0][2][1]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char str[] = "balututorial.com";
   str[1]++;
   str[2] = 100;
   puts(str);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char str[] = "abcdef";
    str[3] = 0;
    puts(str);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char str[] = "abcdef";
   ++str;
   ++*str;
   puts(str);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  char s[4][40] = {
    "abc",
    "123",
    "xyz"
  };
  char * p[4] = {
    "pascal",
    "cobol"
  };
  printf("\n%d", sizeof(s));
  printf("\n%d", sizeof(p));
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char s1[40] = "Hello Balu";
    char * s2 = "Balututorial.com";
    char * s3 = "Balu";
    s3 = s2 + 2;
    s2 = s1 + 2;
    ++*s2;
    ++*s3;
    puts(s1);
    puts(s2);
    puts(s3);
    return 0;
  }

c interview questions for beginners

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   short num[3][2] = {3,6,9,12,15,18};
   printf("%d   %d", *(num + 1)[1], **(num + 2));
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  long arr[2][4] = {0l,1l,2l,3l,4l,5l,6l,7l};
  printf("%ld\t", arr[1][2]);
  printf("%ld%ld\t", *(arr[1] + 3), 3[arr[1]]);
  printf("%ld%ld%ld\t", *( * (arr + 1) + 2), *(1[arr] + 2), 3[1[arr]]);
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a = 2, b = 4, c = 8;
   int* arr1[2] = {&a,&b};
   int* arr2[2] = {&b,&c};
   int* (*arr[2])[2] = { &arr1,&arr2};
   printf("%d %d\t", *( * arr[0])[1], *(*(**(arr + 1) + 1)));
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a = 5, b = 10, c = 15;
   int* arr[3] = {&a,&b,&c};
   printf("%d", * arr[ * arr[1] - 8]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[][3] = {
     {
       1,2
     },
     {
       3,4,5
     },
     {
       5
     }
   };
   printf("%d %d %d", sizeof(arr), arr[0][2], arr[1][2]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int arr[][4] = {
      {
        7,8,9
      },
      {
        3,13
      },
      {
        10, 20,30
      }
    };
    printf("\n%d ", arr[1][1]);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  int arr[5] = { 10,20};
  printf("\n%d %d ", 1[arr], arr[0]);
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  int arr1[5] = {10,20};
  int arr2[5];
  printf("\n%d %d ", arr1[3], arr2[3]);
  return 0;
}

c interview questions for freshers

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  int array[10] = { 5};
  printf("%d %d", xxx[1], array[9]);
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  long double a;
  signed char b;
  int arr[sizeof(!a + b)];
  printf("%d", sizeof(arr))
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int i = 3;
   int* j;
   int** k;
   j = &i;
   k = &j;
   printf(" % u % u % d", k, *k, **k);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char arr[10];
   arr = "world";
   printf("%s", arr);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int *p1, **p2;
   double* q1,**q2;
   printf("%d %d ", sizeof(p1), sizeof(p2));
   printf("%d %d", sizeof(q1), sizeof(q2));
   return 0;
 }

c array interview questions

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a = 5, b = 10, c = 15;
   int * arr[] = {&a,&b,&c};
   printf("%d", * arr[1]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int a[2][4] = {3,6,912,15,18,21,24};
    printf("%d %d %d", *(a[1] + 2), *(*(a + 1) + 2), 2[1[a]]);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   const int x = 25;
   int* const p = & x;
   *p = 2*x;
   printf("%d", x);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char arr[] = "balututorial.com";
    float* fptr;
    fptr = (float*)arr;
    fptr++;
    printf("%s", fptr);
    return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   char arr[] = "balututorial.com";
   char* p;
   p += 3;
   p = arr;
   p += 3;
   *p = 100;
   printf("%s", arr);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a[5] = {10, 20,30,40,50};
   int b[5] = {3,13 };
   b = a;
   printf("%d", b[1]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  int a[5] = {6,16,26};
  ++*a;
  ++*(a + 1);
  ++a[1];
  printf("%d %d", a[0], a[1]);
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a[5] = {10,20,30,40,50};
   int* ptr;
   ptr = a + 1;
   printf("%d %d %d", ++ * ptr, * ptr++, *++ptr);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char str[] = "abcdefghxyz";
    printf("\n%s", str);
    printf("\n%s", str + 4);
    printf("\n%s", str + 8);
    return 0;
  }

fresher c interview questions

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   short num[3][2] = {3,6,9,12,15,18};
   printf("%d  %d", *(num + 1)[1], **(num + 2));
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
int main() {
  int array[2][3] = {5,10,15,20,25,30};
  int(* ptr)[2][3] = & array;
  printf("%d\t", ***ptr);
  printf("%d\t", ***(ptr + 1));
  printf("%d\t", **(*ptr + 1));
  printf("%d\t", *(*(*ptr + 1) + 2));
  return 0;
}

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[][3] = {
     {
       1,2
     },
     {
       3,4,5
     },
     {
       5
     }
   };
   printf("%d %d %d", sizeof(arr), arr[0][2], arr[1][2]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    char array[] = "balu \0 tutorial";
    char * str = "balu \0 tutorial";
    printf("%s %c\n", array, array[2]);
    printf("%s %c\n", str, str[2]);
    printf("%d %d\n", sizeof(array), sizeof(str));
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[];
   arr[1] = 10;
   printf("%d", arr[0]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[2] = {10,20,30,40};
   printf("%d", *(arr + 2));
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int arr[2] = {10,20};
    arr[2] = 30;
    arr[3] = 40;
    printf("%d", *(arr + 3));
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[2] = {10,20};
   *arr = 30;
   *(arr + 1) = 40;
   printf("%d %d", arr[0], 1[arr]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a = 10;
   int* p = & a;
   int** pp = & p;
   ++*p;
   ++**pp;
   a*= a - 2;
   printf("\n%d ", a);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int a[] = { 7,18,29};
   int* p;
   p = a;
   ++p;
   printf("%d %d %d", p[-1], p[0], p[1]);
   return 0;
 }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int arr[4][8] = {10,20,30};
    printf("\n%d ", sizeof(arr));
    printf("\n%d ", sizeof(arr[1]));
    printf("\n%d ", sizeof(arr[1][0]));
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
  int main() {
    int arr[4][8] = {10,20,30};
    printf("\n%d ", & arr[3][4] - & arr[1][2]);
    return 0;
  }

What will be output if you will execute the following c code?

#include<stdio.h>
 int main() {
   int arr[3][] = {
     {
       7, 8,9
     },
     {
       3,13
     },
     {
       10, 20,30
     }
   };
   printf("\n%d ", arr[1][1]);
   return 0;
 }

Leave a Reply

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