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

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is dynamic data structure?

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

C & C Plus Plus
Edit

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?

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. intmain()
  3. {
  4.     printf(“10%%”);
  5.     getchar();
  6.     return0;
  7. }
  • Output:

10 %

Developed by: