Computer SciencePractice Assignment: random( ) Function
Nita Arora,KHMS, Ashok Vihar(c)
Consider the following program code. Select the expected output(s) from theoptions(i) to (iv)
#
include<iostream.h>
#
include<stdlib.h>void main(){clrscr();int N=20,guess;randomize();for(int i=1;i<=3;i++){guess=random(N-10)+10;cout<<guess<<" ";}}
i)
9 12 14 ii) 14 12 17 iii) 12 14 11 15 iv) 11 14 22
3
(d)
Mark the correct answer(s) with justification
#
include<iostream.h>
#
include<stdlib.h>
#
include<conio.h>void main(){randomize();int num,rndnum;num=7;rndnum=random(num)+7 ;for(int n=1;n<=rndnum;n++)cout<<n<<" ";getch();}
i) 1 2 3 4 5 6 7 8ii) 1 2 3 4 5 6 7 8 9 10 11 12 13iii) 0 1 2 3 4 5 6 7 8 9iv) 1 2 3 4 5 6 7 8 9 10 11 12 13 14
3
(e)
In the following program, find the correct possible output(s) from the options:
#
include<stdlib.h>
#
include<iostream.h>void main(){randomize();char City[][10]={³DEL´,´CHN´,´KOL´,´BOM´,´BNG´};int Fly;for(int I=0;I<3;I++)
(2)
Add a Comment