COMPUTER SCIENCE C++

1. f) Observe the following program SCORE.CPP carefully, if the value of Num entered by the user is 5, choose the correct possible output(s) from the options from (i) to (iv), and justify your option.

//Program: SCORE.CPP
#include<stdlib.h>
#include<iostream.h>
void main( )
{ randomize( );
int Num,Rndnum;
cin>>Num;
Rndnum = random(Num) + 5;
for(int N = 1;N<=Rndnum;N++)
cout<<N<<” “; }

Output Options:

(i) 1 2 3 4
(ii) 1 2
(iii) 1 2 3 4 5 6 7 8 9
(iv) 1 2 3

2

Ans:Expected Output:

(iii) 1 2 3 4 5 6 7 8 9

2005 Outside Delhi :

1.b) Name the header files to which the following belong:(i) puts( ) (ii)isalnum( )

1

Ans) (i) puts( ) - stdio.h (isalnum( ) - ctype.h

1.c) Rewrite the following program after emoving the syntactical error(s), if any. Underline each correction.

#include<iostream.h>
const int dividor 5;
void main( )
{ Number = 15;
for(int Count=1;Count=<5;Count++,Number -= 3)
if(Number % dividor = = 0)
cout<<Number / Dividor;
cout<<endl;
else
cout<<Number + Dividor <<endl;

2

Ans:

#include<iostream.h>
const int dividor= 5;
void main( )
{ int Number = 15;
for(int Count=1;Count<=5;Count++,Number -= 3)
if(Number % dividor = = 0)
{ cout<<Number / Dividor;
cout<<endl;
}
else
cout<<Number + Dividor <<endl;
}

 

CBSE Computer Science Solved Revision Tour By Mr. Ravi Kiran ( mrkdata@yahoo.com )


Warning: include_once(../../ebooks-footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp11.php on line 129

Warning: include_once(): Failed opening '../../ebooks-footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp11.php on line 129

Warning: include_once(../../../footer19.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp11.php on line 131

Warning: include_once(): Failed opening '../../../footer19.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/ebooks/xii/coumputer-science/cpp11.php on line 131