Can include files be nested?

Can includefiles be nested?

Ans. Yes. Include files can be nested any number of times.As long as you use precautionary measures, you can avoid including the samefile twice. In the past, nesting header files was seen as bad programmingpractice, because it complicates the dependency tracking function of the MAKEprogram and thus slows down compilation.

When should we use pointers in a C program?
Ans. a)To get address of a variable
b) For achieving pass by reference in C  Pointers allow different functions to shareand modify their local variables.
c)Topass large structures so that complete copy of the structure can beavoided C.

d)Toimplement  linked  data structures like linked listsand binary trees.

What is thedifference between the = symbol and == symbol?

Ans. The = symbol is often used in mathematical operations.It is used to assign a value to a given variable. On the other hand, the ==symbol, also known as  equal to  or  equivalentto , is a relational operator that is used to compare two values.

What is NULL pointer? 
Ans.  NULL is used to indicate that the pointerdoesn t point to a valid location. Ideally, we should initialize pointers as NULLif we don t know their value at the time of declaration. Also, we should make apointer NULL when memory pointed by it is deallocated in the middle of aprogram.

What is thedifference between calloc() and malloc() ?

Ans. calloc(...) allocates a block of memory for an array ofelements of a certain size. By default the block is initialized to 0. The totalnumber of memory allocated will be (number_of_elements * size).

malloc(...) takes in only asingle argument which is the memory required in bytes. malloc(...) allocatedbytes of memory and not blocks of memory like calloc(...).

What is a nestedloop?

Ans. A nested loop is a loop that runs within another loop.Put it in another sense, you have an inner loop that is inside an outer loop.In this scenario, the inner loop is performed a number of times as specified bythe outer loop. For each turn on the outer loop, the inner loop is firstperformed.

What is thedifference between printf() and sprintf() ?

Ans. sprintf() writes data to the character array whereasprintf(...) writes data to the standard output 1device.

What is syntaxerror?

Ans. Syntax errors are associated with mistakes in the useof a programming language. It maybe a command that was misspelled or a commandthat must was entered in lowercase mode but was instead entered with an uppercase character. A misplaced symbol, or lack of symbol, somewhere within a lineof code can also lead to syntax error.

What is Dangling pointer?
Ans.  Dangling Pointer is a pointer that doesn tpoint to a valid memory location. Dangling pointers arise when an object isdeleted or deallocated, without modifying the value of the pointer, so that thepointer still points to the memory location of the deallocated memory.

What are variablesand it what way is it different from constants?

Ans. Variables and constants may at first look similar in asense that both are identifiers made up of one character or more characters(letters, numbers and a few allowable symbols). Both will also hold aparticular value.  Values held by a variable can be altered throughout theprogram, and can be used in most operations and computations. Constants aregiven values at one time only, placed at the beginning of a program. This valueis not altered in the program.

How to reduce afinal size of executable?

Ans. Size of the final executable can be reduced usingdynamic linking for libraries.

How do you generaterandom numbers in C?

Ans. Random numbers are generated in C using the rand()command. For example  anyNum = rand()will generate any integer number beginning from 0, assuming that anyNum is avariable of type integer.

Share this post

Comments (0)

  • Be first to comment

Leave a comment

or to Comment

Contact Us

  • Address: # 650 Narsi Village Sector 32 Urban Estate Karnal-132001 Haryana, India

  • Phone:(+91) 97289-77666   Email:

Follow Us