YouTube Icon

Interview Questions.

Top 100+ C Preprocessor Interview Questions And Answers - May 27, 2020

fluid

Top 100+ C Preprocessor Interview Questions And Answers

Question 1. What Is Include Directive In C?

Answer :

The encompass directive is used to consist of documents like as we include header documents within the beginning of the program the use of encompass directive like

#encompass

Question 2. What Is Define Directive?

Answer :

It is used to assign names to exclusive constants or statements that are for use again and again in a software. These defined values or declaration may be used by major or inside the person defined functions as well.

DBMS Interview Questions
Question three. What Are # Preprocessor Operator In C?

Answer :

# is referred to as stringize opertor and turns the argument it precede into a quoted string. Use of # is proven within the C Source code given beneath and should be well studied.

Question four. Can A File Other Than A .H File Be Included With #consist of?

Answer :

The preprocessor will encompass whatever file you specify for your #include assertion. Therefore, when you have the road

#consist of 

on your application, the document macros.Inc could be protected on your precompiled program. It is, but, uncommon programming exercise to position any file that doesn't have a .H or .Hpp extension in an #consist of announcement. You ought to continually placed a .H extension on any of your C documents you're going to include. This technique makes it simpler for you and others to perceive which documents are getting used for preprocessing purposes.

C++ Tutorial
Question five. What Are The Advantages Of Using Macro?

Answer :

In modular programming, the usage of features is recommended whilst a certain code is repeated several times in a program. However, everytime a feature is referred to as the manage gets transferred to that function and then lower back to the calling function. This consumes a number of execution time. One way to shop this time is by using the use of macros. Macros substitute a feature call with the aid of the definition of that feature. This saves execution time to a terrific extent.

C++ Interview Questions
Question 6. If You Know Then Define #pragma?

Answer :

The #pragma Directives are used to turn ON or OFF positive functions. They range from compiler to compiler.

Question 7. What Is A Macro In C Preprocessor?

Answer :

A macro is a preprocessor directive that provides a mechanism for token substitute to your supply code. Macros are created through using the #outline assertion. Here is an example of a macro:

#define VERSION_STAMP "1.02"

Java Tutorial C & Data Structures Interview Questions
Question eight. What Is Typedf?

Answer :

The typedef clause may be used in a comparable manner.

Typedef lengthy int int32; /* 32 bit signed integer */

The typedef is favored over the #outline due to the fact is better included into the C language, and it is able to create greater varieties of variable kinds than a trifling outline.

Question 9. What Is The Mean Of Function?

Answer :

Functions allow for modular programming. You have to remember the fact that all parameters surpassed into feature in C are exceeded via fee!

Java Interview Questions
Question 10. What Is #define?

Answer :

The #define directive can be used to outline kinds, which includes:

#define INT32 lengthy int /* 32 bit signed integer type */

Go (programming language) Tutorial
Question eleven. What Is ## Preprocessor Operator In C?

Answer :

## is known as the pasting opertor which is used to concates two tokens. Use of ## is proven within the supply code.

Go (programming language) Interview Questions
Question 12. What Is The General Form Of #line Preprocessor?

Answer :

General shape of #line preprocessor is #line wide variety "filename"

Here the record call is non-compulsory. Filename string replaces the string value of _ _FILE_ _ whilst the quantity modifications the fee of _ _LINE_ _.

The foremost use of #line is in debugging and rare programming state of affairs.

Following C Source code indicates the #line preprocessor in movement -

#encompass 
int essential ()

printf ("npercentd", __LINE__); //Prints 6
#line 100;
printf ("npercentd",__LINE__); // Prints one hundred and one
printf ("npercentd", __FILE__);// Prints original source report name
#line 103 "Super C"
printf ("npercentd", __FILE__); //Prints Super C
return zero;


DBMS Interview Questions
Question thirteen. What Is File In C Preprocessor?

Answer :

This macro shops the document call of the source report being compiled

F Sharp (programming language) Tutorial
Question 14. What Is Line In C Preprocessor?

Answer :

This a dynamic macro which shops the line range of the road currently being compiled. Value is continuously updated as compiler moves ahead.

Question 15. What Is #line?

Answer :

#line preprocessor is used to alternate the values of 2 MACROS , _ _LINE _ _ and _ _ FILE _ _.

F Sharp (programming language) Interview Questions
Question 16. What Is #error And Use Of It?

Answer :

The use of this preprocessor is in debugging. Whenever this preprocessor is encountered in the course of compilation the compiler could prevent compilation and show the mistake message related to the preprocessor in complation Output/Result Window. Depending upon compiler any other debugging facts may even accompany your mistakes message.

General form of #error is -

#error message

Also be aware that message doesnot need to be in double rates.

Following supply code show using #errors preprocessor directive in C -

#consist of 
int main ()

#error I am Error and while i'm right here i will no longer allow this application collect :-) .
Go back 0;


R Programming language Tutorial
Question 17. Where Define Directive Used?

Answer :

Defining a consistent
Defining a announcement
Defining a mathematical expression
For instance

#outline PI 3.141593
#define TRUE 1
#define floatingpointno waft
R Programming language Interview Questions
Question 18. What Are The Preprocessor Categories?

Answer :

Macro substitution division
File inclusion division
Compiler manipulate division
C++ Interview Questions
Question 19. What Are Types Of Preprocessor In C?

Answer :

#outline and #undef - Used for defining and undefining MACROS.
#blunders - Used for Debugging
#include - Used for combining source code documents
#if, #else, #elseif, and #endif - Used for conditional compilation just like if - else statment.
#ifdef and #ifndef - Conditional Compilation on basis of #outline and #undef
#line - Controls this system line and file macros.
#pragma - Used for giving compiler guidance. Highly specific to the compiler getting used.
# and ## - Operators used for stringize and concating operation respectively.
D Programming Language Tutorial
Question 20. What Are The Advantages Of C Preprocessor?

Answer :

Programs less difficult to broaden,
Easier to examine,
Easier to alter
C code more portable among unique gadget architectures.
D Programming Language Interview Questions
Question 21. What Is C Preprocessor Mean?

Answer :

The C preprocessor is a tool which filters your source code before it is compiled. The preprocessor lets in constants to be named the use of the #define notation.It is in particular useful for selecting gadget established pieces of code for one-of-a-kind computer kinds, permitting a unmarried software to be compiled and run on several special computers.

Question 22. What Is Cpp?

Answer :

The preprocessor is referred to as cpp, however it's miles known as mechanically by way of the compiler so that you will not need to name it whilst programming in C.

Lua (programming language) Tutorial
Question 23. Do You Have Any Idea About The Use Of "automobile" Keyword?

Answer :

When a sure variable is declared with the key-word ‘vehicle' and initialized to a positive value, then inside the scope of the variable, it's far reinitialized upon being called again and again.

Lua (programming language) Interview Questions
Question 24. Can You Please Explain The Scope Of Static Variables?

Answer :

Static variables in C have the scopes;

 Static international variables declared on the top level of the C supply document have the scope that they cannot be seen outside to the supply report. The scope is limited to that record.
 Static nearby variables declared inside a feature or a block, additionally referred to as nearby static variables, have the scope that, they may be seen simplest inside the block or characteristic like nearby variables. The values assigned through the functions into static neighborhood variables all through the primary call of the function will persist / present / to be had till the characteristic is invoked again.
The static variables are to be had to this system, not most effective for the feature / block. It has the scope in the modern-day assemble. When static variable is asserted in a feature, the fee of the variable is preserved , so that successive calls to that function can use the contemporary updated price. The static variables are initialized at assemble time and saved in the executable file itself. The existence time extends throughout the whole run of the program.

Static neighborhood variables have neighborhood scope. The difference is, garage length. The values placed into the neighborhood static variables, will nevertheless be present, while the feature is invoked subsequent time.

C & Data Structures Interview Questions
Question 25. What Do You Know About The Use Of Bit Field?

Answer :

Packing of information in a structured format is allowed via using bit fields. When the memory is a top rate, bit fields are extremely useful. For example:

Picking more than one items into a machine phrase : 1 bit flags can be compacted
Reading external record formats : non-popular file formats might be read in, like nine bit integers
This form of operations is supported in C language. This is executed by using placing :'bit length' after the variable. Example:

struct packed_struct 
unsigned int var1:1;
unsigned int var2:1;
unsigned int var3:1;
unsigned int var4:1;
unsigned int var5:four;
unsigned int funny_int:nine;
 p.C.;

packed-struct has 6 contributors: four of 1 bit flags every, and 1 four bit kind and 1 9 bit funny_int.

C packs the bit fields within the shape automatically, as compactly as viable, which presents the maximum duration of the sector is less than or same to the integer phrase length the computer system.

The following factors want to be mentioned whilst working with bit fields:

The conversion of bit fields is continually integer type for computation
Normal types and bit fields will be blended / combined
Unsigned definitions are crucial.
Question 26. Tell Us Bitwise Shift Operators?

Answer :

The bitwise operators are used for transferring the bits of the primary operand left or right. The variety of shifts is designated with the aid of the second operator.

Expression << or >> number of shifts

Ex:

range<<3;/* number is an operand - shifts 3 bits towards left*/

number>>2; /* variety is an operand – shifts 2 bits towards right*/

The variable variety need to be an integer cost.

For leftward shifts, the proper bits the ones are vacated are set to 0. For rightward shifts, the left bits those are vacated are filled with zero's based totally at the type of the first operand after conversion.

If the cost of ‘range' is 5, the primary declaration in the above example consequences forty and stored in the variable ‘variety'.

If the value of ‘quantity' is 5, the second one announcement in the above instance effects 0 (0) and stored inside the variable ‘quantity'.

Embedded C Interview Questions




CFG