Saturday, October 4, 2025

C Interview Questions & Answers || Freshers Level || Set - II

 Question: What is C Language? 

Answer: C is a general-purpose and procedural language. The C programming language offers low-level access to system memory. Any program written using C must be run via a C compiler to transform it into an executable code for any computer to run.

Question: What is a token? 

Answer: A token can be described as the smallest unit required for creating a C program. Every punctuation and word in a C program can be called a token. A compiler will segment a C program into various tokens before proceeding to the different stages of a compilation process.

Question: Why is C called a mid-level programming language? 

Answer: C is called a mid-level language because it combines the characteristics of low-level and high-level languages. It is machine-independent like a high-level language, even though it can support pointer arithmetic like a low-level language. Programs written using the C language are converted into assembly code.

Question: What is the use of printf() and scanf() functions? 

Answer: The scanf() and printf() functions are useful for inputs and outputs in the C programming languages. These are in-built library functions defined in the header file called stdio.h.

Question: Why is the static variable used in C? 

Answer: The static variable in the C programming language is utilized for the following purposes:

  • It is useful for retaining the value of multiple function calls.

  • Its wide scope makes it accessible anywhere in the C program.

  • It is treated as a common value, shared by all methods.

  • It is initialized a single time in the memory heap to minimize memory usage.

Question: What is a built-in function in C? 

Answer: The C compiler creates inline code for built-in functions during compile time. Calling a built-in function can remove the runtime call to the function having the exact name in the dynamic library.

Question: What is recursion in C? 

Answer: Recursion involves making a function call itself. This valuable technique is useful for breaking complicated programs into simple ones.

Question: What is the difference between global int and static int declaration? 

Answer: The difference stems from where they can be declared. Global variables are always required to be declared outside the primary function. Static variables can be declared inside as well as outside the primary function.

Question: What is a pointer in C? 

Answer: Pointers in C are variables that store the memory address of other variables in the form of their value.

Question: How is const char* p different from char const* p? 

Answer: Const char*p denotes a constant character. Char*const p refers to a constant pointing toward a character.

Question: How are macros in the C programming language different from functions? 

Answer: The differences include:

  • Code Length: Macros can increase code length, while functions cannot affect the code length.

  • Processing: Macros need to be preprocessed, while functions need to be compiled.

  • Execution Speed: Macros can help increase the execution speed, while function execution speed is somewhat lower.

  • Substitution/Control: Before compilation, the macro value replaces the macro name, while transfer of control will occur during the function call.

  • Error Checking: Macros won’t consider errors during compile time, while functions will check all errors during compile time.

…till next post, bye-bye & take care.

No comments:

Post a Comment