Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

COMSATS University Islamabad

Wah Campus

Assignment # 02
Programming Fundamentals

SUBMITTED BY:
FA22-BCS-144-Ahmad Ali

SUBMITTED TO:
Mr. Taimur Sajjad

Date: 3/25/23
 Which of the following is the possible output from the invoking rand()?
323.4, 5, 34, 1, 0.5, 0.234
The output of the rand () function are integers, so the possible output of this rand ()
function is 5, 34 and 1.
a) How do you generate a random integer I such that 0<=i<20?

Output:

b) How do you generate a random integer I such that 0<=i<=20?


Output:

c) How do you generate a random integer I such that 0<=i<=50?

Output:
d) Find out what RADN_MAX is on your machine.

Output:

Question 2
Write a program which ask user to generate a random number between 1
and 3 and print apple if random number is 1, prints grapes if random
number is 2 and prints peach if random number is 3 (using switch
statement)
Output:

You might also like