rn
Set 4 – Technical questions. Read and learn!
rnQuestion 1: What is wrong in this statement?
rnscanf(%d,whatnumber);
rnAnswer:
rnAn 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.
rnQuestion 2: What does the format %10.2 mean when included in a printf statement?
rnAnswer:
rnThis 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.
rnQuestion 3: What are linked list?
rnAnswer:
rnA 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.
rnQuestion 4: What are binary trees?
rnAnswer:
rnBinary 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.
rnQuestion 5: Differences between C and Java?
rnAnswer:
rnQuestion 6: In header files whether functions are declared or defined?
rnAnswer: Functions are declared within header file. That is function prototypes exist in a header file, not function bodies. They are defined in library (lib).
rnQuestion 7: What are the different storage classes in C?
rnAnswer:
rnThere are four types of storage classes in C. They are extern, register, auto and static.
rnQuestion 8: What does static variable mean?
rnAnswer:
rnStatic 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.
rnQuestion 9: How do you print an address?
rnAnswer:
rnUse %p in printf to print the address.
rnQuestion 10: What are macros? What are its advantages and disadvantages?
rnAnswer:
rnMacros 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.