From d4bee5dc6356a0fdc17494d331f347697b2d8fe7 Mon Sep 17 00:00:00 2001 From: bhattshubham15 Date: Wed, 23 Oct 2019 11:54:16 +0530 Subject: [PATCH] initial commit --- random.pas | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 random.pas diff --git a/random.pas b/random.pas new file mode 100644 index 0000000..7d8cda7 --- /dev/null +++ b/random.pas @@ -0,0 +1,22 @@ +{ Program to demonstrate the Random and Randomize functions. } + +Var I,Count,guess : Longint; + R : Real; + +begin + Randomize; { This way we generate a new sequence every time + the program is run} + Count:=0; + For i:=1 to 1000 do + If Random>0.5 then inc(Count); + Writeln ('Generated ',Count,' numbers > 0.5'); + Writeln ('out of 1000 generated numbers.'); + count:=0; + For i:=1 to 5 do + begin + write ('Guess a number between 1 and 5 : '); + readln(Guess); + If Guess=Random(5)+1 then inc(count); + end; + Writeln ('You guessed ',Count,' out of 5 correct.'); +end. \ No newline at end of file