Languages-C & C Plus Plus [TCS Placement]: Sample Questions 79 - 80 of 119

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 79

Describe in Detail Essay▾

What is dynamic data structure?

Edit

Explanation

  • Dynamic data structure provides a means for storing data more efficiently into memory.
  • Using dynamic memory allocation, program allocates memory spaces as needed.
  • Contrast this with static data structure, wherein the programmer has to indicate fixed memory space to be used in the program.
  • Dynamic data structures grow and shrink as memory is allocated and deallocated from heap.
  • Dynamic data structures allocate blocks of memory from the heap and link those blocks into data structure using pointers.
  • When the data structure no longer needs a block of memory, it will return the block to the heap for reuse.
Given the Image is Define the Dynamic Data Structures and Example

Question 80

Describe in Detail Essay▾

The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

Edit

Explanation

  • This is done by using %% in the printf statement.
  • For example, printf ( “10%%” ) will output “10%” on the screen.
  • The format string is composed of zero or more directives: ordinary characters (not %) , which are copied unchanged to the output stream; and conversion specifications for each of the arguments
  • The character % is followed by one of the following characters.
  • The flag character
  • The field width
  • The precision
  • The length modifier
  • The conversion specifier:
  • So we can print “%” using “%%” .
  • Example
  1. #include<stdio.h>
  2. int main()
  3. {
  4. printf(“10%%”);
  5. getchar();
  6. return 0;
  7. }
  • Output:

10%