Languages [3i Infotech Placement]: Sample Questions 535 - 537 of 546

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 535

Edit

Write in Short

Short Answer▾

What is function that extracts a sub string from a given string?

Explanation

  • Substring (string, position [, count] )
  • Extract substring starting from start and going for count characters.
  • If count is not specified, the string is clipped from the start till the end

Question 536

Edit

Describe in Detail

Essay▾

How would you use the functions randomize () and random () ?

Explanation

randomize () :

  • Randomize initializes the random number generator with a random value.
  • Randomize is implemented as a macro that calls the time function prototyped in time. h
  • Include time. h when we use this routine

random () :

  • The function random () returns a pseudo random integral number.
  • This number will be in the range 0 to RAND_MAX.
  • The algorithm of rand () uses a seed to generate the series of numbers based on a seed- srand must be used to initialize the seed to some distinctive value.
  • The constant RAND_MAX is defined in standard library.
  • Return value:
  • Will return an integer value between 0 and RAND_MAX.

Question 537

Question

MCQ▾

Purpose of PC (Program Counter) in a Microprocessor is

Choices

Choice (4)

a.

To store address of next instruction to be executed

b.

Count the number of instructions

c.

To store base address of the stack

d.

To store address of TOS (Top Of Stack)

Answer

a.

Explanation

The program counter, PC, is a special-purpose register that is used by the processor to hold the address of the next instruction to be executed. It automatically gets incremented to point to the next instruction during the op-code decode cycle. When computer is reset or gets restarted, Program Counter normally reverts to 0.

Developed by: