Sie sind auf Seite 1von 5

CLASS XI - COMPUTER SCIENCE - WORKSHEET

HEADERS AND RANDOM


Some Standard C++ libraries
Nome Purpose
Header
iostream.h
stdio.h
ctype.h
string.h
math.h
stdlib.h

Defines stream classes for input/output streams


Standard input and output
Character tests
String operations
Mathematical functions such as sin() and cos()
Utility functions such as malloc() and rand()

Some functions
isalpha(c)-check whether the argument is alphabetic or not.
islower(c)- check whether the argument is lowecase or not.
isupper(c) - check whether the argument is upercase or not.
isdigit(c)- check whether the argument is digit or not.
isalnum(c)- check whether the argument is alphanumeric or not.
tolower()-converts argument in lowercase if its argument is a letter.
toupper(c)- converts argument in uppercase if its argument is a letter.
strcat()- concatenates two string.
strcmp-compare two string.
pow(x,y)-return x raised to power y.
sqrt(x)-return square root of x.
random(num)-return a random number between 0 and (num-1)
randomize- initializes the random number generator with a random value.

Name the header files that shall be needed for the following code:
void main( )
{ char word[]=Board Exam;
cout<<setw(20)<<word;
}
Name the Header file to which the following built in functions belongs to:
o gets() (ii) abs()
(iii) sqrt()
(iv) open()

3) Name the header file(s) that shall be needed for successful compilation of the
following C++ code.
void main( )
{
char String[20];
gets(String);
strcat(String,CBSE);

puts(String);
}
In the following program, if the value of Guess entered by the user is 65, what
will be the expected output(s) from the following options (i), (ii), (iii) and (iv)? 2
#include <iostream.h>
#include <stdlib.h>
void main()
{
int Guess;
randomize();
cin>>Guess;
for (int I=1;I<=4;I++)
{
New=Guess+random(I);
cout<<(char)New;
}
}
(i) ABBC
(ii) ACBA
(iii) BCDA
(iv) CABD
In the following program, if the value of N given by the user is 20, what maximum and minimum
values the program could possibly display? [2]
#include <iostream.h>
#include <stdlib.h>
void main( )
{
int N, Guessnum;
randomize ();
cin >>N;
Guessnum = random (N-10 ) + 10;
cout << Guessnum <<endl;

In the following code, what will be the possible output from the following options
i to iv ?Justify the answer.
# include<iostream.h>
#include<conio.h>
#include<stdlib.h>
const int LIMIT=4;
void main()

{
randomize ( );
int Points;
Points=100 + random (LIMIT);
for(int P=Points;P>=100; P- -)
cout<<P<<#;
cout<<endl;
}
i) 103#102#101#100#
ii) 100#101#102#103#
iii) 100#101#103#102#104#
iv) 104#103#102#101#100#

(a) Name the header file, to which following built-in function belong:
(1) Cgets
(2) Floor
(3) isalpha
4 Gets

5 (ii) remove()

(iii) abs()

4) Name the header file(s) that shall be needed for successful compilation of the
following C++ code
.
void main( )
{
char Text[40];
strcpy(Text,AISSCE);
puts(Text); }
5)Name the header file to which the following below:
(i) abs( )
(ii) isupper( )
6) Name the header file to which the following belong:
(i)pow ( )
(ii)random( )
7) Name the header files to which the following belong:
(i)abs( )
(ii) strcmp( )
8)Name the header files to which the following belong: [AI 2005]
(i)puts( )
(ii) isalnum( )

9)Write the names of the header files to which the following belong:
(i) gets( )
(ii) strcmp( ) (iii)abs( )
(iv)isalnum( )
10)Name the header file, to which the following built in function belongs:
(i)strcmp( ) (ii)getc( )
11)Name the header files of C++ to which the following functions belong:
(i)get( ) (ii)open( ) (iii)abs( ) (iv)strcat( )
12) Name the header file to be included for the use of the following built in functions:
(i)getc( ) (ii)strcat()
13)Name the header file, to which following built in function belong:
(i)isupper( ) ii)setw() (iii)exp( ) (iv)strcmp( )
14)
Why main( ) function is so special. Give two reasons?
15)Name the header file of C++ to which following functions belong.
(i)strcat( ) (ii) scanf( ) (iii) getchar( ) (iv)clrscr( )
16)Name the header files, to which the following built in functions belongs to:
(i)cos( )(ii)setw( )(iii)toupper( )(iv)strcpy( )
17) Name the header files, to which the following built in functions belongs to:
(i)cos( )(ii)setw( )(iii)toupper( )(iv)strcpy( )
18)Name the header file to, which following built in functions belong:
(i)strcpy() isdigit() ii) log()
19)Name the header file to be included for the use of following
(i)frexp() (ii)toupper() write() arc() open() strlen()
Sequence
control
statement(if)
Syntax
if(expression)
{
statements;
}

conditional
statement
(if else)
Syntax
If(expression)
{
statements;
}
else
{
statements;
}

case control
(switch case)

statement

Syntax
switch(integral expression)
{case (int const expr1):
[statements
break;]
case (int const expr2):
[statements,
break;]
default:Statements;}

Precedence of operators:

loop control statement


(while ,do while, for)
Syntax
while(expression)
{statements;}
do .while loop
do
{statement;} while(expression);
for loop
for(expression1;expression2;expression3)
{statement;}

++(post increment),--(post decrement)


++(pre increment),--(pre decrement),sizeof !(not),-(unary),+unary plus)
*(multiply), / (divide), %(modulus)
+(add),-(subtract)
<(less than),<=(less than or equal),>(greater than), >=(greater than or equal to)
==(equal),!=(not equal)
&& (logical AND)
||(logical OR)
?:(conditional expression)
=(simple assignment) and other assignment operators(arithmetic assignment
operator)
, Comma operator

Highes
t

Low

Das könnte Ihnen auch gefallen