Ten Technical Interview/Aptitude Questions for you – Set 4

Ten Technical Interview/Aptitude Questions for you – Set 4

 

rn

Set 4 – Technical questions. Read and learn!

rn

Question 1: What is wrong in this statement? 

rn

scanf(%d,whatnumber);

rn

Answer:

rn

An ampersand ‘&’ symbol must be placed before the variable name whatnumber. Placing & means whatever integer value is entered by the user is stored at the “address” of the variable name. This is a common mistake for programmers, often leading to logical errors.

rn

Question 2: What does the format %10.2 mean when included in a printf statement?

rn

Answer:

rn

This format is used for two things: to set the number of spaces allotted for the output number and to set the number of decimal places. The number before the decimal point is for the allotted space, in this case it would allot 10 spaces for the output number. If the number of space occupied by the output number is less than 10, addition space characters will be inserted before the actual output number. The number after the decimal point sets the number of decimal places, in this case, it’s 2 decimal spaces.

rn

 Question 3: What are linked list?

rn

Answer:

rn

A linked list is composed of nodes that are connected with another. In C programming, linked lists are created using pointers. Using linked lists is one efficient way of utilizing memory for storage.

rn

 Question 4: What are binary trees?

rn

Answer:

rn

Binary trees are actually an extension of the concept of linked lists. A binary tree has two pointers, a left one and a right one. Each side can further branch to form additional nodes, which each node having two pointers as well.

rn

Question 5: Differences between C and Java?

rn

Answer:

rn
    rn
  1. JAVA is Object-Oriented while C is procedural.
    2. Java is an Interpreted language while C is a compiled language.
    3. C is a low-level language while JAVA is a high-level language.
    4. C uses the top-down approach while JAVA uses the bottom-up approach.
    5. Pointer goes backstage in JAVA while C requires explicit handling of pointers.
  2. rn
rn

 Question 6: In header files whether functions are declared or defined?

rn

Answer: Functions are declared within header file. That is function prototypes exist in a header file, not function bodies. They are defined in library (lib).

rn

Question 7: What are the different storage classes in C?

rn

Answer:

rn

There are four types of storage classes in C. They are extern, register, auto and static.

rn

Question 8: What does static variable mean?

rn

Answer:

rn

Static is an access qualifier. If a variable is declared as static inside a function, the scope is limited to the function, but it will exists for the life time of the program. Values will be persisted between successive calls to a function.

rn

 Question 9: How do you print an address?

rn

Answer:

rn

Use %p in printf to print the address.

rn

Question 10: What are macros? What are its advantages and disadvantages?

rn

Answer:

rn

Macros are processor directive which will be replaced at compile time.
The disadvantage with macros is that they just replace the code they are not function calls. Similarly the advantage is they can reduce time for replacing the same values.

c