C Interview Questions Videos

In the C Interview Questions Video Series, we will discuss hundreds of C problems which are generally asked in various company interviews, and competitive exams. In every video, we will discuss in-depth, one interview or exam question in C so that one can have a deeper understanding of the C language. We will discuss these interview questions with a code walkthrough in the lab as well as a line-by-line explanation of the C code.

The “C Interview Questions” video series is available on Youtube free of cost and Manish sir, our Founder & CTO is the instructor for these videos. We will be uploading 1-2 videos per week, so subscribe to the Sanfoundry-Youtube channel for upcoming videos. Watch the complete C Interview Question Series playlists below:

 
 
Also, join the C language technical discussion group at Telegram: SanfoundryClasses
 
Here’s the latest video:

advertisement

C Interview Question 10

List of C Interview Questions and Solutions Videos:

  • C Interview Question #1 | C Interview Solution #1
  • In this C interview question, we will discuss multiple occurrences of pre-increment, post-increment, pre-decrement, and post-decrement operators in a single expression. In this question, we are incrementing and decrementing an integer variable ‘a’ multiple times in an expression ++a + a++ + –a. In some situations, the expressions are valid whereas in other situations, the expression is invalid and the C language doesn’t have a valid or fixed answer. So, various C compilers (GNU-GCC, Microsoft compiler, Mac) can have different answers in some of these situations.

  • C Interview Question #2 | C Interview Solution #2
  • This C interview question focuses on the usage of sizeof operator of C language and its side effect on the various variables while evaluating the expression containing sizeof operators. In this C problem, we are pre-incrementing an integer ‘b’ and also assigning the expression to another integer ‘c’ i.e., c = ++b + 1. All of this is happening inside sizeof() operator. The key is to understand the purpose of the sizeof operator.

  • C Interview Question #3 | C Interview Solution #3
  • In this video on C interview question, we have a character pointer to a string i.e., char *p = “SAN”; and we are trying to change or manipulate the content of the string. The focus is to check if the interviewee understands the concepts of pointers in C.

  • C Interview Question #4 | C Interview Solution #4
  • In this C interview question video, we are assigning a value of 255 to a character data-type and then trying to display the output using printf() function of C. We are testing the candidate’s understanding of printf() function as well as their understanding of a few rules of C language.

    advertisement
    advertisement
  • C Interview Question #5 | C Interview Solution #5
  • In this interview problem in C, we are assigning ASCII values to 2 character variables i.e., char c1 = ‘a’, c2 = ‘b’, c; and then doing an addition operation and then comparing the results of this character addition with another higher value. The goal is to test a deeper knowledge of the interviewee on data-types in C.

  • C Interview Question #6 | C Interview Solution #6
  • In this C interview question, we are creating bit-fields using structures in C i.e., int f1:3; unsigned int f2:1; and then doing a few initialization operations on the bitfields. This will allow us to test the interviewee’s knowledge on bit fields with a detailed understanding of values for those bit positions.

  • C Interview Question #7 | C Interview Solution #7
  • This interview problem on C tests a candidate’s understanding of the concepts of arrays and array initialization. In this problem, we are partially initializing an array int a[5] = {1, 2, 3} and then printing the content for the un-initialized portion.

  • C Interview Question #8 | C Interview Solution #8
  • In this C interview question video, we are assigning a value of 128 to a character data-type and then trying to display the output of the program. We are testing the candidate’s understanding of the range of character data-type in C as well as their detailed understanding of usage of printf() function.

    advertisement
  • C Interview Question #9 | C Interview Solution #9
  • In this interview question in C language, we are assigning a value to an integer variable i.e., int x = 4 * 1024; and then doing a few arithmetic operations (multiply operation) on that integer. Sometimes, this type of arithmetic operation won’t work as expected. We are testing the candidate’s understanding of what’s going on behind the scenes in C language and why the answers are not as expected. The candidate is supposed to give a solution to that problem.

  • C Interview Question #10 | C Interview Solution #10
  • In this C interview question video, we are getting sizeof the integer data type in C and then comparing it with another integer using a logical operator in C. In some software engineering designs, this type of comparison fails to work as expected. We are testing the interviewee’s understanding of various rules of the C programming language and why the answers are not as expected. The candidate is supposed to identify the real problem and then explain the solution.

  • C Interview Question #11
  • In this interview question on C language, we are working on float data type. The goal is to test the interviewee’s understanding of the rules of C language with respect to the float and double data types and their conversions. In the given code, we are assigning a value to a float variable f, and then comparing it with the same value using ‘if’ conditions to check the assigned value and the actual value stored in the variable f.

  • C Interview Question #12
  • In this C problem, we are assigned a value of -1 to a character variable c and then printing its value using printf() function of the C library. We are testing the knowledge of the interviewee if they know the range of values of a data type and how functions like printf() will behave if the values are not in the range.

  • C Interview Question #13
  • In this classic C interview problem, we are working on void and ‘void *’ (void pointer) data types and trying to check the expected behavior of sizeof() operator on them. The candidate should be able to reason out the outcomes of such operations.

    advertisement
  • C Interview Question #14
  • In this C question, we have two pointer variables p and q, and we are doing arithmetic operations on pointers. Pointer arithmetic in C is very special and certain arithmetic operations like addition and subtraction are permitted whereas multiplication and division are not permitted. Moreover, there is an effect of scaling factor on pointer arithmetic. In the given code, we are doing subtraction on pointers to arrive at a final value. The goal is to test the interviewee’s knowledge of pointer arithmetic and scaling factor in C language.

  • C Interview Question #15
  • In this C language interview question, we have two integers x and y to which are applying pre and post-increment operators in a conditional if expression. Moreover, we are also using logical OR operation in the if condition for various outcomes of the expression. The candidate should be able to identify the outcome of the expression based on pre and post-increment operations and their variation.

  • C Interview Question #16
  • In this C interview problem, we are printing the size of char and ‘char *’ (character pointer) data types. This is a fundamental test on data types and their sizes. The output also depends on the computer architecture. This question tests the user understanding of memory allocation by the compiler for the fundamental data type (character data type) as well as its dependency on various computer hardware.

  • C Interview Question #17
  • In this C interview question, we are assigning a value of 12, 0x12, 012 respectively to three integer variables x, y, and z. Subsequently, we are displaying their values using printf(). This question tests the user’s understanding of various number systems in computing and their assignment and usage in C language. The interviewee should be able to answer correctly why the printf() function is displaying different values for these variables.

  • C Interview Question #18
  • In this interview question on C language, we are having an integer pointer p and it’s pointing to an integer variable a. Subsequently, we are using * indirection operation (de-referencing operation) and ampersand operations on pointer variable and displaying the values. The problem becomes more interesting when we apply de-referencing and address operators to ordinary integer variables as well. The candidate should be able to give correct answers to these operations with correct reasoning.

    advertisement
  • C Interview Question #19
  • In this C interview question, we have two integers a and b which are initialized to values of 8 and 4 respectively. We are doing a conditional if expression along with bitwise AND operator on these two integer variables. We are testing the interviewee’s knowledge of bitwise operations. The candidate should know bitwise operators in good detail and should be able to answer the outcome of such expressions.

  • C Interview Question #20
  • In this C problem, we have 3 integers x, y, and z which are initialized to values of 1, 0, and 1 respectively. We are doing post-increment operations on these variables along with logical “AND” and “OR” operations. The interviewee must have knowledge of such pre and post-increment operations in C along with a detailed understanding of operator precedence and short circuit behaviour of C programming language to solve these types of problems.

  • C Interview Question #21
  • In this C interview problem, we have 4 integers a, b, c, and d which are initialized to values of 1, 1, 3, and 4 respectively. We are doing a complex expression on these 4 variables which involve pre and post-increment operators along with nesting of ternary operators in C. We are testing the interviewee’s understanding of ternary operators, its rule of nesting, and the knowledge of sequence points to solve such a complex expression.

  • C Interview Question #22
  • In this interview question in C, we have 2 integers a and b which are initialized to values of 2 and 4 respectively. We are doing a conditional if expression along with comma operator to test the understanding of the interviewee with respect to comma operator in C.

  • C Interview Question #23
  • In this C interview question, we have 3 integers i,j, and k. We are doing various arithmetic operations like division and multiplication on these 3 variables. The candidate must have a detailed knowledge of rules of operator precedence and associativity in C language to solve this question.

  • C Interview Question #24
  • In this interview question on C language, we are having a pointer p which is pointing to an integer array of 4 elements ‘int a[4]’. We are doing arithmetic operations on this pointer p. The interviewee must have a detailed knowledge of pointers and scaling factor to give the correct answer to the expression used in the printf() function.

  • C Interview Question #25
  • In this C interview question, we are printing the string “Sanfoundry Surprise” in an infinite while loop. The program won’t behave as expected. We are testing the interviewee’s knowledge of the C library as they must have a detailed understanding of the standard C library and its input/output streams to explain the behavior of this C program.

Important Links:

advertisement
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & technical discussions at Telegram SanfoundryClasses.