Skip to content

Basic 40+Frequently Asked Interview Questions on C

Interview Questions on C


1. What is the C language?

Ans: C is a high-level and general-purpose programming language.


2. Who is the founder of C?

Ans: Dennis Ritchie is the founder of the C language.


3. What are the advantages of the C language?

Ans: Some advantages of C language:

  • Low-level language
  • Structured programming Language
  • Produces efficient programs
  • Produces portable programs
  • Powerful programming language
  • Memory Management
  • Fast Speed

4. What are datatype in the C language?

Ans: Data-Types is a permissible way in which data or information can be represented inside a C program.


5. What are predefined data types in C:

  •  char
  • int
  • float
  • Double
  • Long

6. What is variable in C?

Ans: Variables are simply names used to refer to some location in memory – a location that holds a value with which we are working. It may help to think of variables as a placeholder for a value. You can think of a variable as being equivalent to its assigned value.


7. What is Keyword in C?

Ans: Keywords are predefined, reserved words used in C Language that have special meanings to the compiler. Keywords are part of the syntax.


8. How many keywords are in C?

Ans: There are a total of 32 Keywords in C:

  • auto
  • break
  • case
  • char
  • const
  • continue
  • default
  • do
  • double
  • else
  • enum
  • extern
  • float
  • for
  • goto
  • if
  • int
  • long
  • register
  • return
  • short
  • signed
  • sizeof
  • static
  • struct
  • switch
  • typedef
  • union
  • unsigned
  • void
  • volatile
  • while

9. What are Arithmetic operators in C?

Ans: Arithmetic operators, in C, are operators used to perform arithmetic operations that include multiplication, division, addition, and subtraction.


10. List of Arithmetic operators available in C?

Ans:

  • +addition
  • – Subtraction
  • * Multiplication
  • / division
  • % remainder after division ( modulo division)

11. What are Relational operators in C?

Ans: In C programming we can compare the value stored between two variables and depending on the result we can follow different blocks using Relational Operator in C.


12. List of Relational operators available in C?

Ans:

== Check if two operands are equal

!= Check if two operands are not equal

> Check if the operand on the left is greater than the operand on the right.

< Check operand on the left is smaller than the right operand

>= Check left operand is greater than or equal to the right operand.

<= Check if the operand on left is smaller than or equal to the right operand.


13. What are Logical operators in C?

Ans: Logical operators are used to combining two or more conditions/constraints or to complement the evaluation of the original condition in consideration.


14. List of Logical operators available in C?

Ans:

&& Logical And

|| Logical OR

! Logical Not


15. What are Bitwise operators in C?

Ans: Bitwise operators perform manipulations of data at bit level. These operators also perform the shifting of bits from right to left and left to right.


16. List of Bitwise operators available in C?

Ans:

& Bitwise AND

| Bitwise OR

^ Bitwise exclusive OR

<< Left Shift

>> Right Shift


17. What are assignment operators in C?

Ans: Assignment Operators are used to assigning value to a variable. Assignment Operator is denoted by equal to sign. An assignment operator is a binary operator which operates on two operands.


18. List of Assignment Operators available in C?

Ans:

= assigns the value from the right side operand.

+= adds right operands to the left operand and assigns the result to the left operand and assigns the result to left.

-= Subtracts right operands from the left operand and assigns the result to the left operand.

*= Multiply the left operand with the right operand and assign the result to the left operand.

/= Divides left operand with the right operand and assigns the result to the left operand.

%= Calculate modulus using two operands and assign the result to the left operand.


19. What is a Conditional operator in C?

Conditional operators return one value if the condition is true and returns another value if the condition is false. This operator is also called a ternary operator.


20. What are decision-making statements in C?

Ans: Decisions making a statement is depending on the condition block needs to be executed or not which is decided by condition. If the condition is “true” statement block will be executed, if a condition is “false” then the statement block will not be executed. There are mainly three decision-making statements. If statement, if-else statement, switch statement.


21. What is the looping statement in C?

Ans: Looping statement is the statements execute one or more statement repeatedly several numbers of times. In loop first, check the condition if the condition is true then control goes inside the loop body otherwise goes outside the body. There are mainly three types of loop statements

  • For loop
  • While loop.
  • Do-While loop

22. What is Pointer in C?

Ans: A pointer is a variable that contains the address in memory of another variable. We can have a pointer to any variable type.

The unary operators & gives the “address of a variable”.


23. What is String in C?

Ans: Strings are actually a one-dimensional array of characters terminated by a null character “\0”.


24. What is Union in C?

Ans: A union is a special user-defined data type in C that allows storing different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given type.


25. What is the Bitfield in C?

Ans: C permits us to use small bit fields to hold data. We have been using an integer field of size 16 bit to score data. The data items require much less than 16 bits of space, in such case we waste memory space. In this situation, we use small bit fields in the structure.


26. What are processors in C?

Ans: The C preprocessor is a macro preprocessor that transforms your program before it is compiled. These transformations can be the inclusion of header files, macro expansions, etc.


27. What is the header in C?

Ans: A header file is a file containing C declaration and macro definitions and macro definitions to be shared between several source files.


28. What is Recursion in C?

In programming languages, If a program allows you to call a function inside the same function, then it is called a recursive call of the function.


29. What is a pointer on a pointer?

Ans: It’s a pointer variable that can hold the address of another pointer variable.


30. What is a Static variable?

Ans: A static local variable retains its value between the function call and the default value is 0. If a global variable is static then its visibility is limited to the same source code.


31. What is a NULL pointer?

Ans: A pointer pointing to nothing is called a NULL pointer.


32. What is the meaning of the base address of the array?

Ans: The starting address of the array is called the base address of the array.


33. What is a dangling pointer?

Ans: A pointer initially holding a valid address, but later the held address is released or freed. Then such a pointer is called a dangling pointer.


34. Can a program compiled without a main() function definition?

Ans: Yes, it can be but cannot be executed, as the execution requires a main() function definition.


35. What is a nested structure?

Ans: A structure containing an element of another structure as its member is referred to.


36. What is a NULL statement?

Ans: A null statement is no executable statement.


37. Can we typecast a float variable to a long integer variable?

Ans: Yes, with loss of fractional part.


38. What is the return value of a relational operator?

Ans: Return a value 1 if the relationship between the expression is true, else 0.


39. What is an infinite loop?

Ans: A loop executing repeatedly as the loop-expression always evaluates to true.


40. What is a string length?

Ans: It is the count of characters in the char array excluding the ‘\0’ character.


41. What is the purpose of #undef preprocessor?

Ans: It is used to undermine an existing macro definition.


42. Can a function return multiple values to a caller using the return keyword?

Ans: No, only one value can be returned to the caller.


43. What is a constant pointer?

Ans: A pointer that is not allowed to be altered to hold another address after it is holding one.


44. Is there a way to compare two structure variables?

Ans: There is no much. We need to compare element by element of the structure variables.


45. Can the main() function left empty?

Yes, the possibility of the program doing nothing.


The complete knowledge is written from @HiteshChoudhary…Thanks for

Leave a Reply

Your email address will not be published.

%d bloggers like this: