Skip to content

Commit 7801e7b

Browse files
committed
[Shreyash]: Added code to find min max from 3-digit five random num using if-else
1 parent 73db90c commit 7801e7b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Write a program that reads 5 Random 3 Digit values and then outputs the minimum and the maximum value
3+
*/
4+
5+
// generating Five 3-digits Random numbers
6+
const num1 = Math.floor(Math.random() * 898 + 101);
7+
const num2 = Math.floor(Math.random() * 898 + 101);
8+
const num3 = Math.floor(Math.random() * 898 + 101);
9+
const num4 = Math.floor(Math.random() * 898 + 101);
10+
const num5 = Math.floor(Math.random() * 898 + 101);
11+
console.log("\n The Random Five 3 digit Numbers are: "+ num1 + ", " + num2 + ", " + num3 + ", " + num4 + ", " + num5);
12+
13+
//initialize the minimum number is num1
14+
let min = num1;
15+
if (num2 < min)
16+
{min = num2};
17+
if (num3 < min)
18+
{min = num3};
19+
if (num4 < min)
20+
{min = num4};
21+
if (num5 < min)
22+
{min = num5};
23+
console.log("\n Minimum number is = " + min);
24+
25+
//initialize the maximum number is num1
26+
max = num1;
27+
if (num2 > max)
28+
{max = num2};
29+
if (num3 > max)
30+
{max = num3};
31+
if (num4 > max)
32+
{max = num4};
33+
if (num5 > max)
34+
{max = num5};
35+
console.log("\n Maximum number is = " + max , "\n")

0 commit comments

Comments
 (0)