C Programming Question and Answers

25. What is stack memory allocation and dynamic memory allocation?
 
  • The compiler allocates the required memory space for a declared variable. By using the address of a operator, the reserved address is obtained and this address may be assigned to a pointer variable. Since, most of the declared variable has static memory, this way of assigning pointer value to a pointer variable is known as static memory allocation. Memory is assigned during compilation time.
  • Dynamic memory allocation: it uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these functions are assigned to pointer variables, such assignments are known as dynamic memory allocation. Memory is assigned during run time.
 
Your Name Your Email-ID
Your Answer
26. How do you declare a variable that will hold string values?
  The char keyword can only hold I character value at a time. By creating an array of characters, you can store string values in it.
 
Your Name Your Email-ID
Your Answer
27. What is the difference between top down approach and bottom up approach in programming languages?
 
  • Top down approach and bottom up approach are involved in software development. These approaches are not involved in program execution.
  • Structure/procedure oriented programming languages like C programming language follows top down approach. Whereas object oriented programming languages like C++ and Java programming language follows bottom up approach.
  • Top down approach begins with high level design and ends with low level design or development. Whereas, bottom up approach begins with low level design or development and ends with high level design.
  • In top down approach, main() function is written first and all sub functions are called from main functions. Then sub functions are written based on the requirements. Whereas, in bottom up approach, code is developed for modules and then these modules are integrated with main() function.
  • Nowadays, both approaches are combined together and followed in modern software design.
 
Your Name Your Email-ID
Your Answer
28. What is a newline escape sequence?
 
  • A newline escape sequence is represented by the character.
  • This is used to insert a new line when displaying data in the output screen.
  • More spaces can be added by inserting more characters.
  • For example, would insert two spaces. A newline escape sequence can be placed before the actual output expression or after.
 
Your Name Your Email-ID
Your Answer
123456789101112


131415 Page 7 of 15