+3 votes
in Class 12 by kratos

The following code is from a game, which generates a set of 4 random numbers. Praful is playing this game, help him to identify the correct option(*) out of the four choices given below as the possible set of such numbers generated from the program code so that he wins the game. Justify your answer.

include<iostream.h>

include<stdlib.h>

const int LOW=25;

void main() {

randomize ();

int POINT=5,Number;

for(int I=1;I<=4;I--)

{

Number=LOW+random(POINT);

cout<<Number<<":";

POINT--;

}

}

(i) 29:26:25:28:

(ii) 24:28:25:26:

(iii) 29:26:24:28:

(iv) 29:26:25:26:

1 Answer

+1 vote
by kratos
 
Best answer

(iv) 29: 26: 25: 26: is correct

Justification:

The only option that satisfied the values as per the code is option (iv) because when:

| I | POINT | Number |
| Minimum | Maximum |
| 1 | 5 | 25 | 29 |
| 2 | 4 | 25 | 28 |
| 3 | 3 | 25 | 27 |
| 4 | 2 | 25 | 26 |

...