text: C Programming Interview Questions And Answers for beginners/experienced professionals from Codingcompiler. These Adobe Analytics interview questions were asked in various interviews conducted by top multinational companies across the globe. We hope that these interview questions on C programming will help you in cracking your next C Programming job interview. All the best and happy learning..
  C programming Interview Questions
  - What is C programming Language?
  - Why is C known as a mother language?
  - What are the key features of C programming language?
  - What is the use of header files in C?
  - Can a program be compiled without the main() function?
  - What are the basic data types in C?
  - What are different storage class specifiers in C?
  - What is scope of a variable? How are variables scoped in C?
  - What is a pointer on pointer?
  - Distinguish between malloc() & calloc() memory allocation
  C programming Interview Questions and Answers
  Q. What is C programming Language?
  C Language Introduction. C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. Like syntax of Java, PHP, JavaScript, and many other languages are mainly based on C language.
  Q. Why is C known as a mother language?
  Q. What are the key features of C programming language?
  C is a platform-dependent language.
  C offers the possibility to break down a large program into small modules.
  Also, the possibility of a programmer to control the language.
  C comes with support for system programming and hence it compiles and executes with high speed when compared to other high-level languages.
  Q. What is the use of header files in C?
  Header files contain the definitions and set of rules of the functions being used in the programs.
  For example, when you use printf() or scanf() in your program, you nee to include stdio.h library function. Else your compiler will show an error. This is because, the standard input and output functions printf() and scanf() are stored in this header file.
  So similarly every header file stores a set of predefined functions which makes it easy to program.
  Q. Can a program be compiled without the main() function?
  Yes, compilation is possible, but the execution is not possible. However, if you use #define, we can execute the program without the need of main().
  For Example:
  #include <stdio.h>
  #define start main
  void start() {
  printf(“Hi”);
  }
  Q. What are the basic data types in C?
  Int – Used to represent a number (integer)
  Float – Used to represent a decimal number
  Double – Used to represent a decimal number with highest precision(digits after the decimal point)
  Char – Single character
  Void – Special purpose type without any value
  Q. What are different storage class specifiers in C?
  Ans: auto, register, static, extern
  Q. What is scope of a variable? How are variables scoped in C?
  Ans: Scope of a variable is the part of the program where the variable may directly be accessible. In C, all identifiers are lexically (or statically) scoped.
  Q. What is a pointer on pointer?
  It’s a pointer variable which can hold the address of another pointer variable. It de-refers twice to point to the data held by the designated pointer variable.
  Eg: int x = 5, *p=&x, **q=&p;
  Therefore ‘x’ can be accessed by **q.
  Q. Distinguish between malloc() & calloc() memory allocation.
  Both allocates memory from heap area/dynamic memory. By default calloc fills the allocated memory with 0’s.
  Frequently asked C programming Interview Questions and Answers
  Q. What is keyword auto for?
  By default every local variable of the function is automatic (auto). In the below function both the variables ‘i’ and ‘j’ are automatic variables.
  void f() {
  int i;
  auto int j;
  }
  NOTE − A global variable can’t be an automatic variable.
  Q. What is a static.
  Q. What is a NULL pointer?
  A pointer pointing to nothing is called so. Eg: char *p=NULL.
  Q. What do you mean by Dangling Pointer Variable in C Programming?
  Ans: A Pointer in C Programming is used to point the memory location of an existing variable. In case if that particular variable is deleted and the Pointer is still pointing to the same memory location, then that particular pointer variable is called as a Dangling Pointer Variable.
  Q. What do you mean by a Nested Structure?
  Ans: When a data member of one structure is referred by the data member of another function, then the structure is called a Nested Structure.
  Q. What is a C Token?
  Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.
  Q. What is a preprocessor?
  And: In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. We’ll refer to the C Preprocessor as CPP. Returns true if this macro is not defined. Tests if a compile time condition is true.
  Q. What is the task of preprocessor?
  The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control. In many C implementations, it is a separate program invoked by the compiler as the first part of translation.
  Q. What is a C Token?
  Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.
  Q. What is the process to create increment and decrement stamen in C?
  Ans: There are two possible methods to perform this task.
  1) Use increment (++) and decrement (-) operator.
  Example When x=4, x++ returns 5 and x- returns 3.
  2) Use conventional + or – sign.
  When x=4, use x+1 to get 5 and x-1 to get 3.
  Q. Describe Wild Pointers in C?
  Ans: Uninitialized pointers in the C code are known as Wild Pointers. These are a point to some arbitrary memory location and can cause bad program behavior or program crash.
  Q. What are the valid places to have keyword “Break”?
  Ans) The purpose of the Break keyword is to bring the control out of the code block which is executing. It can appear only in Looping or switch statements.
  Q. What is the use of printf() and scanf() functions?.
  Advanced C Programming Interview Questions and Answers
  Q. What is recursion in C?
  When a function calls itself, and this process is known as recursion. The function that calls itself is known as a recursive function.
  Recursive function comes in two phases:
  - Winding phase
  - Unwinding phase
  Winding phase: When the recursive function calls itself, and this phase ends when the condition is reached.
  Unwinding phase: Unwinding phase starts when the condition is reached, and the control returns to the original call.
  Example of recursion
  #include <stdio.h>
  int calculate_fact(int);
  int main()
  {
  int n=5,f;
  f=calculate_fact(n); // calling a function
  printf(“factorial of a number is %d”,f);
  return 0;
  }
  int calculate_fact(int a)
  {
  if(a==1)
  {
  return 1;
  }
  else
  return a*calculate_fact(a-1); //calling a function recursively.
  }
  Output:
  factorial of a number is 120
  Q. What is static memory allocation?
  - In case of static memory allocation, memory is allocated at compile time, and memory can’t be increased while executing the program. It is used in the array.
  - The lifetime of a variable in static memory is the lifetime of a program.
  - The static memory is allocated using static keyword.
  - The static memory is implemented using stacks or heap.
  - The pointer is required to access the variable present in the static memory.
  - The static memory is faster than dynamic memory.
  - In static memory, more memory space is required to store the variable.
  For example:
  int a[10];
  The above example creates an array of integer type, and the size of an array is fixed, i.e., 10.
  Q. What is a union?
  The union is a user-defined data type that allows storing multiple types of data in a single unit. However, it doesn’t occupy the sum of the memory of all members. It holds the memory of the largest member only.
  In union, we can access only one variable at a time as it allocates one common space for all the members of a union.
  Syntax of union
  union union_name
  {
  Member_variable1;
  Member_variable2;
  Member_variable n;
  }[union variables];
  Q. Write an example program of Union?
  #include<stdio.h>
  union data
  {
  int a; //union members declaration.
  float b;
  char ch;
  };
  int main()
  {
  union data d; //union variable.
  d.a=3;
  d.b=5.6;
  d.ch=’a’;
  printf(“value of a is %d”,d.a);
  printf(“\n”);
  printf(“value of b is %f”,d.b);
  printf(“\n”);
  printf(“value of ch is %c”,d.ch);
  return 0;
  }
  Output:
  value of a is 1085485921
  value of b is 5.600022
  value of ch is a
  In the above example, the value of a and b gets corrupted, and only variable ch shows the actual output. This is because all the members of a union share the common memory space. Hence, the variable ch whose value is currently updated.
  Q. What is an auto keyword in C?.
  C programming Interview Questions and Answers for experienced
  Q. Why N++ Executes Faster Than N+1?
  Answer :
  The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas n+1 requires more instructions to carry out this operation.
  Q. Differentiate Between A Linker And Linkage?
  Answer :
  A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable.
  Q. What Is Storage Class And What Are Storage Variable?
  Answer :
  A storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. There are five types of storage classes.
  auto.
  static.
  extern.
  typedef.
  Q. How Do You Print An Address?
  Answer :
  The safest way is to use printf () (or fprintf() or sprintf()) with the %P specification. That prints a void pointer (void*). Different compilers might print a pointer with different formats. Your compiler will pick a format that’s right for your environment.
  If you have some other kind of pointer (not a void*) and you want to be very safe, cast the pointer to a void*:
  printf (“%Pn”, (void*) buffer);
  Q. What Does It Mean When A Pointer Is Used In An If Statement?
  Answer :
  Any time a pointer is used as a condition, it means “Is this a non-null pointer?” A pointer can be used in an if, while, for, or do/while statement, or in a conditional expression.
  Q. Is Null Always Defined As 0?).
  Q. How Do You Print Only Part Of A String?
  Answer
  /* Use printf () to print the first 11 characters of source_str. */
  printf (“First 11 characters: ‘%11.11s’n”, source_str);
  Q. Can A Variable Be Both Const And Volatile?
  Answer :.
  Q. What is modular programming?
  Answer:
  Modular programming is a program design technique in which a large program is divided into sub programs/ functions that are called modules, it improve maintainability of a program. It makes software development, debug, modify, update faster and easy.
  Q. What is full form of ARM ?
  Advance RISC(Reduced Instruction Set Computer) Machine.
  Top C programming Interview Questions and Answers
  Q. What is the difference between printf() and puts() ?
  Answer
  The function printf() writes the data on standard output device with the ability of formatted string using %c, %d, %s, %20s .. etc and printf does not add new line after displaying text.
  int printf(const char *format, …);
  puts() writes the string on standard output device and add new line after displaying text.
  int puts(const char *s);
  Q. What is sizeof() ?
  It is a built in operator in c language, it returns the size of any variable/value in bytes.
  printf(“%d,%d”,sizeof(int),sizeof(1.23));
  Q. What are the return type of malloc() and calloc(), how can we use?
  malloc() and calloc() both functions return void* (a void pointer), to use/capture the returned value in pointer variable we convert it’s type.
  Suppose we create memory for 10 integers then we have to convert it into int*.
  1
  2
  int *ptr;
  ptr=(int*)malloc(N*sizeof(int));
  Here, malloc() will return void* and ptr variable is int* type, so we are converting it into (int*).
  Q. What are called and calling functions?
  Parent function which calls any function is known as calling function and the function which is being called is know as calling function.
  Consider the examples:
  1
  2
  3
  4
  int main()
  {
  abcFunc()
  }
  Here, abcFunc() is called within main() function, so main() is called, while abcFunc() is calling function.
  Q. Difference b/w sentinel control loop & counter control Loop?
  In Counter Controlled loop, we know that exactly how many times loop body will be executed while in Sentinel Controlled loop we don’t know about the loop recurrence, Execution of loop is based on condition not counter.
  Consider the example:
  /*****Counter Control loop*****/
  for(i=0;i<10;i++)
  {
  //Body of the loop
  }
  /*****Sentinel Control loop*****/
  while( n>0)
  {
  n=n/10;
  }
  Q. What is an rvalue?
  rvalue can be defined as an expression that can be assigned to an lvalue. The rvalue appears on the right side of an assignment statement.
  Unlike an lvalue, an rvalue can be a constant or an expression, as shown here:
  int x, y;
  x = 1; /* 1 is an rvalue; x is an lvalue */
  y = (x + 1); /* (x + 1) is an rvalue; y is an lvalue */
  And assignment statement must have both an lvalue and an rvalue. Therefore, the following statement would not compile because it is missing an rvalue:
  int x; x = void_function_call() /* the function void_function_call() returns nothing */
  If the function had returned an integer, it would be considered an rvalue because it evaluates into something that the lvalue, x, can store.
  Q. What does the modulus operator do?
  The modulus operator (%) gives the remainder of two divided numbers. For instance, consider the following portion of code:
  x = 15/7
  If x were an integer, the resulting value of x would be 2. However, consider what would happen if you were to apply the modulus operator to the same equation:
  x = 15%7
  The result of this expression would be the remainder of 15 divided by 7, or 1. This is to say that 15 divided by 7 is 2 with a remainder of 1.
  The modulus operator is commonly used to determine whether one number is evenly divisible into another. For instance, if you wanted to print every third letter of the alphabet, you would use the following code:
  int x;
  for (x=1; x<=26; x++)
  if ((x%3) == 0)
  printf(“%c”, x+64);
  The preceding example would output the string “cfilorux”, which represents every third letter in the alphabet.
  Q. What
  Q..
  Q. refer a storable variable in memory. It cannot be a constant.
  Q..