Documente Academic
Documente Profesional
Documente Cultură
COMPUTER SCIENCE
CLASS - XI
1. Write the name of the header files to which the following built in functions belong:
i) exit(0)
ii) clrscr( )
iii) setw() iv ) sqrt ()
v) getch()
2. Find the output of the following program:
#include<iostream.h>
void main( )
{
long NUM = 1234543;
int F = 10, S = 20;
int Rem = NUM% 10;
if (Rem % 2 !=0)
F+ =R;
else
S+ = R;
NUM/=10;
cout<<F-S; }
3. What will be the output of the following code fragment . Justify your answer ?
int f = 1 , a = 2 ;
if ( + + a < 5 )
{
f * = a;
}
cout << f =
<< f ;
4. int a =11 , b = 20 , c = 40;
a = - - c + ++ b / c ;
cout << a = << a ;
5. Rewrite the following statements in terms of switch-case statement
char code; cin>> code; if ( code == R ) cout << Rs. 4 ;
else if (code == W || code == G ) cout << Rs . 10 ;
else cout << Rs . 12 ;
6. Write the output if the statements are executed thrice
var1= 1; var2 = 11;
{
cout << var1++ <<
cout << var2-- <<
9) State the basic units of the computer, Name the subunits that make up the CPU and
give the function of each of the units.
{
int val, res, n=1000;
cin>>val;
res = n+val >1750 ? 400:200;
cout<<res;
}
(i) if val=2000 (ii) if val=1000
(iii) if val=500
6) Evaluate:
i) (120)10 = ( X)2
ii) (110001)2=(X)10
iii) (0100011)2=(X)10
iv) (97)10=(X)2
III 1) Write a C++ program to check a year for leap year or not.
.
2) Write a C++ program to print day of the week corresponding to the number (1-7)
entered using switch case statement.
3) Write a C++ program to design a menu for calculator and calculate the following
operations :
1 for addition,2 for subtraction,3 for multiplication, 4 for division, 5 for exit the
program.
b) c = d * a +b
c) c = (a++) * d + a
d) f = ( ++b) * b - a
e) c = a (b++) * (--a)
14. Write a program to input any alphabet ( lower case / upper case ) from the keyboard
and then display one of the following messages
i) If < char > is a lower case letter , the message
The Upper case character corresponding to <char > is ..
ii) If < char > is a Upper case letter , the message
The Lower case character corresponding to <char > is ..
iii) if <char> is not a letter the message < char> is not a letter
15. What is a loop ? Write the different types of looping constructs in C++ .
16. Write code to print the following series
1) 2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50
2) 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40
3) Sum of numbers from 1 to 100.