VATSALYA INTERNATIONAL SCHOOL -BORSAD QUESTION BANK 2012-13 COMPUTER SCIENCE CLASS : XI

salamiblackΗλεκτρονική - Συσκευές

27 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

85 εμφανίσεις



VATSALYA INTERNATIONAL SCHOOL
-
BORSAD

QUESTION BANK





2012
-
13

COMPUTER SCIENCE




CLASS : XI

Q1



a) What is an operating system? Write its types?









b) What is the difference b/w Data & Information?






c) (i) Storage of 1 KB means the following number of bytes :

1) 1000 2) 964 3) 1042 4) 1024





(ii) One Megabyte is eq
uivalent to
:

1) 210 Bytes 2) 220 Bytes 3) 230 Bytes 4) None of these.





d
)

Suggest suitable devic
e or media for the following:









1) High Quality print.

2) Quiet Printing

3) Economical printing of small quantities of
data


Q2



a) What is the difference b/w
“if
-
else”

& “
Switch case
” ?









b) What are data types? What are all predefined data types in c++?




c) What will
be the size of following constants?
‘v’,”v”,




d) Write the corresponding C++ expressions for the following mathematical
e
xpress
ions:





i) √ (a
2
+b
2
+c
2
) (ii) p+q/(r+s)
4



e) Evaluate the following, where a, b, c are int
egers and d, f are floating point numbers.




The value of a=8, b=4 and d=2.5


1.
f = a * b + a/b


2.
c = d+a + b % a


f)

Which of the following are hardware and software?






(i) Central Processing Unit (ii)
Internet Explorer (iii) Hard disk (iv) UNIX

Q3

a) What is the output of the followi
ng?











i) # include<iostream.h>



void main ( )




{





int ch=20;




cout << ++ch <<”
\
n”<< ch<<”
\
n”;





}

1)

Wha
t output does the above code fragment produce?

2)

What is the effect of replacing ++ch with ch+1?



ii) # include<iostream.h>






void

main( )




{




a=3;




a=a+1;




if (a>5)






cout<<a;





else





cout<<(a+5);



}












iii
) Rewrite the following using if else
:




char code;


cin>> code;


switch(code)


{


case ‘A’ : cout<<”Grade A”;


case ‘B’ : cout<<”Grade B”;


case ‘C’ : cout<<”Grade C”;


break;


case ‘D’ : cout<<”Grade D”;


default:


cout<<”Grade F”;


}


















i
v) What output will be the following code fragment produce?



void main( )




{






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








b)

Out of RISC, CISC and EPIC processors, which supports the most parallelism?




c
)

What is the difference b/w Interpreter & compiler?






d
)

State the basic units of the computer, Name the subunits that make up the CPU and

give the
function of each of the units.





e
)

What are three types of computers? How do they differ?



f
) What is the difference between sema
ntics error and syntax error? Give an example of

each.


Q4
.

Find the error from the following code segment and rewrite the corrected code underlining the
correction made.





a)

# include(iostream.h)


void mains ( )


int X,Y;


cin>>X;


cout>>y;



if x= =y


cout<<Y+X;


else


cout>>Y; }




b)
Convert the following code segment into switch case construct.



int ch;

cin>>ch;

If(ch = = 1)

{

cout<<“ Laptop”;

}

else If(ch = = 2)

{

cout<<“Desktop ”;

} else if(ch= = 3)

{

cout<<“Notebook”;

} else

{

cout<<“Invalid Choice”;

}

} }

Q5


a
)
Evaluate:








i)
(2AC9)
16
= (?)
2


ii) (11011101.0111)
2
=(X)
10


iii) (FACE)
16
=(X)
8



b
) Find the binary addition of 57 and 59.
c
). Find the 1’s and 2’s complement of 128.


Q
6


a)

What is the difference between 25L and 25?




b)

Convert the following if
-
else to a single con
ditional statement:



if (qty >= 20)



order = max + 5;


else



order = max;












Q
7

a)

Write a C++ program to check a year for leap year or not.





b)

Write a C++ program to print day of the week corresponding to the number (1
-
7)



entered using switch case st
atement.





c)

Write a C++ program to accept monthly salary from the user, find and display




income tax with the help of follo
wing table:





SALARY INCOME TAX



9000 or more 40% of monthly salary



7500
-
8999 30% of monthly salary



7499 0r less 20% of monthly salary




d) Write a c++

program to input a number (n). If the number is odd and positive




Print its square root otherwise print n
5




e) In each of the following cases show how the comment can be placed in a program:





i) Add a

comment sum of three numbers to the statement:





sum=a+b+c;




ii) Add the comment End of Function with the ‘}’.



f) Write a program to find the roots of
a quadratic equation.

Q
8


a).
What is data abstraction and Encapsulation? Explain the concept with the help of an

example.



b)

Evaluate x=
-

-
y +2y if y=3








c)

Find syntax error(s) if any in following program ( Assume all header files are present)




main<>

{ int c;


switch( c );

case 1.5: { cout<<” India is great
\
n”;


} break;

‘case’ 2: { cout<<” hello
\
n”;


} break;

} // end of main

} // end of switch

Q
9

i)

What is the output of the following?


if the input is : a=30 , b=30











i = j = 10 ;












1


if ( a < 100 )



if (

b >50 )



++i;


else



++j;


cout << " i = " << i << "
\
n";


cout << " j = " << j << "
\
n";









ii) What will be the output of the following program segment?







If input is as: (a) a

(b) c



(c) d

(d) h

(e) b


cin >>ch;







switch (ch)


{ case ‘a’: cout<<”Computer Science ”<<"
\
n";


case ‘b’: cout<<”Biology” <<"
\
n";


case ‘c’: cout<<”Chemistry” <<"
\
n";


brea
k;


case ‘d’: cout<<”Accountancy” <<"
\
n";


break;


default: cout<<” wrong choice”;


}


















Q
10
.

d) State the basic units of the computer, Name the
subunits that make up the CPU and give the function
of each of the units.







Q1
1
.

Evaluate the following expressions


x *(++ y)

y % 10 +3

where x=8, y=10, z=8

Q 12.

.

Evaluate the following expressions


(x+y > z) ? ( ++ x


y) : (
-

-

z + ++y) whe
re x=8, y=10, z=8


Q1
3
. Construct logical expressions to represent

the following conditions







i) salary is in the range 8000 to 10000





ii) ch is an uppercase letter



iii) weight is greater than or equal to 30 but less than 50



iv) a is an odd number


Q
1
4

.
Find the error from the following code segment and rewrite the corrected code underlining the correction
made.



a)

# include(iostream.h)

int mains ( )

clrscr;

int num;


cout<<"
\
n enter number"



cin>>num;


for(
int i==1; i<11 ;)


cout<<"
\
n"<<num<<" * " << i << " = " << num * 1

}

Q15.

Convert the following code segment into switch case construct.



#include<iostream.h>

int main()

{

int choice;

double temp,conv_temp;

cout<<"temperature conversion menu"<<"
\
n";

cout<<"1.Farenheit to celcius"<<"
\
n";

cout<<"2.Celcius to Fahrenheit"<<"
\
n";

cout<<"enter your choice(1
-
2):";

cin>>choice;

if(choice==1)

{

cout<<"
\
n"<<"enter
temperature in Fahrenheit:";

cin>>temp;

conv_temp=(temp
-
32)/1.8;

cout<<"The temperature in celcius is"<<conv_temp<<"
\
n";

}

else

{

cout<<"
\
n"<<"enter temperature in celcius:";

cin>>temp;

conv_temp=(1.8*temp)+32;

cout<<"The temperature in Fahrenheit is"<<con
v_temp<<"
\
n";

}

return 0;

}

Q1
6
. Find the error in the following program segment








#include<iostream.h>



void main( )



{

int a,b;




char ch;




cout<<”Enter your choice”;




cin>>ch;


switch(ch);




{ Case 1: c = a+b; cout<<
c;break;




Case 2: c = a*b; cout<<c;break;





Case 3: c = a*b; cout<<c;break;



}}



Q1
7
. The following program is used to find the reverse of a number. Some codes are

m
issing in it. Supply
only the missing codes










void main()



{



int n, rem, rev =0;



cin>>n;



while(_________)



{




rem =_________;




rev = _________;




n = _________;



}



cout<< rev;



}

Q
18
.


a)

Evaluate:






i) Convert (1010100.011)
2

to decimal.

ii) Convert (11011110101110)
2

to hexadecimal.




iii) (FACE)
16
=(?)
8





b
) Find the binary of (22.25)
10






c
)

Find the hexadecimal of (423)
10










Q
19
.

Construct logical expressions to represent the following conditions.





a) fees is in the
range 3000 to 4000 but code is 5.


b) mark is greater than 85 and grade is A

Q2
0
.

Evaluate the following

a) x
-
y<z && y+z >x||x
-
z<=y
-
x+z if x=4, y=8,z=9


b) y&&(x
-
z) || !(2y<z
-
x) if x=10 ,y=11, z=10

Q
2
1
.
a
) Write a C++ program to check whether the given number is palindrome or not.





b)
Program to print whether a given character is an uppercase or a lowercase character or a digit or any
other character. Use ASCII codes are as given b
elow;



characters ASCII Range



'0'
-

'9' 48
-

57



'A'
-

'Z' 65
-

90



'a'
-

'z' 97
-

122



other characters 0
-

255 excluding

the above mentioned codes.

Q22

Write a C++ program to print fibonacci series i.e., 0 1 1 2 3 5 8 .........
.....

Q
23
.

Define function?

Prapare a program using function to calculate the cube of number entered by user.

Q
24
.

Evaluate the following expressions









i) y = ++x + ++x where x=10


ii) !(a<b) && c!= d || b+c < a where a=7, b=3, c=5, d=6


Q
25
.

Change the following For…. Loop structure to while loops






for (j=1;j<=10;++j)



for(k=10;k>=1;
--
k)





cout<<j*k;




cout<<”computer science”;

Q
26
.

a).What is the difference between an object and a class?

b) Evaluate x =
-

-

y + 2y if y=3






c) Write the output of the
following C++ program:








#include <iostream.h>

#include <con
io.h>

int main ()

{

clrscr();

void swap(int,int);

int a,b;

a=7;

b=4;



cout <<"
\
n Original values are:
\
n";

cout <<"a="<<a<<" , b = " << "
\
n" ;

swap ( a,b);

cout <<"
\
n The values after swap() are:
\
n";

cout << "a= " <<a<<" , b = " << b << "
\
n";

getch();

return 0;

}

void swap ( int x, int y)

{

int temp;

temp = x;

x=y;

y=temp;

cout<<"
\
n swapped values are ;";

cout<<"a="<<x<<",b="<<y<<"
\
n";

}

d)Mention the steps you would follow while writing a program.





Q
27
.

What will be the output of the following program statements?





a) #include<iostream.h>


void main( )


{



int a=10,b=8;


for(int i=0;i<=a;i++)



cout<<i<<endl;


for(int j=0;j<=a;j++)



cout<<++j<<endl;


b=a;


++a;


b++;


cout<<a<<”
\
n”<<b<<”
\
n”<<
--
b<<endl;


}


Q
28
.

What will be the output of the following program statements?





#include<iostream.h>











void main( )


{


int i=0,ua=0,ub=0,uc=0,fail=0;


while(i<=5)


{ switch(i++)



{


case 1: ++ua;



case 2: ++ub;


case 3:


case 4: ++uc;


default : ++fail;


}


}


cout<<”ua =”<<ua<<”,ub =”<<ub<<”,uc=”<<uc
<<”,fail=”<<fail;


}


Q
29
.

What will be the output of the following program statements?






#
include<i
ostream.h>












void main( )





{



int a=2,b=5,c=3,m;



m=(a>b) ? c : (( b>c) ? b : c ) ;



cout<<m;



}


Q3
0
.
. Find syntax error(
s), if any, in the following programs.


a) #include(iostream.h)











void main( )


{



int X;



cin>>X;



for(Y=0;Y<10;Y++)




If X= = Y





cout<<Y+X;




else





cout>>Y;



}


Q3
1
.

What will be the output of the following?


a) #include<iostream.h>














void main( )



{ char ch[9] = {‘C’, ‘o’, ‘m’, ‘p’, ‘u’, ‘t’, ‘e’, ’r’, ‘
\
0’ };



cout<<ch[4] << ch[2] <<ch[6];



}

Q3
2
.

What will be the output of the following?


#include<iostream.h>













void main()




{


int U=10, V=20;



for(int i=1; i<=2; i++)


{



cout<<”[1]=”<<U++<<”&”<<V
-
5<<endl;


cout<<”[2]=”<<++V<<”&”<<U+2<<endl;


}




}


Q3
3
.

What will be the output of the following?

#include<iostream.h>












void main( )


{

int x=5, y=3, z=8;



int m= x>y;



int n=z>y;



cout<<”n=”<<n<<endl;



cout<<”m=”<<m<<endl;



cout<<”x=”<<x++<<”y=”<<++y<<”z=”<<z<<endl;



while(m)



{




cout<<m<<“ ”<<n<<endl;




if(m==10)




break;




else




m
-

-
;



}


}



Q
34
.
Identify syntax errors, if any, in the following code fragment







i)




int DIV 5;


void main()


{



Num = 15;



for(

count=1; count<=5; count++)



if(Num % Div = 0)




cout<<Num / Div;




cout<<endl;



else




cout<<Num + Div <<endl;


}


}

Q
35
.


Predict the output of following code segment






int n=7;



cout<<”n++=”<<n++<<”,n=”<<n<<”
\
n”;

Q
36
.

How many times the following loop will be executed?








x=500;


while(x<500)


{ x
-
=600;



if (x<0)



break;


}

Q
37
. Differentiate
between the following.









i) break and exit

ii
) break and continue


ii
i)
Unary, Binary and Ternary operators

i
v) = and ==


v) / and %

Q
38
. Write c++ code to

:

copy one string to other string

Q
39
. What will be the size of the following constants








i) 100


ii) 98.967


iii) ‘ 8 ’


iv) “ * ”

Q4
0
. a) What will be the output o
f the following?


#include<iostream.h>













void main()



{

int a=5, b=5, c=3, ans;



ans = (a < ++b ? b/2 : c/2);



cout<<ans;



}

Q4
1
. What will be the output of the following?



#include<iostream.h>












void main()



{


int A=5, B=10;




for(int i=1; i<=2; i++)



{

cout<< “Line1 =”<<A++<<”&”<<B
-
2<<endl;





cout<< “Line2=”<<++B<<”&”<<A+3<<endl;



}





}

Q
42
. Rewrite the following program using for loop.









void main()


{



int I,j,s
um=0;



i=1;



while(i++<=10)



{ j=1;




while(j++<=10)




sum += 1;






}



cout<<sum;


}

Q
43
.

Write c++ code to

check whether two strings are equal or not

Q
44
.
Name the header files for the following


functions
:

clrscr()


setw()


gets()


toupper( ) putchar()


islower()

sqrt()


strcmp()
setw()


pow()


strlen()


isalpha()

puts()


getchar()

get()


cos()


strcpy()

strlen() ceil()


fabs()

exit()


isalnum()

strupr()
cout()

cin()


getch()

Q
45
.
Write full

form for the following
:
MIPS , CISC , RISC ,CPU ,RAM
, ROM, PROM, EPROM, EEPROM
,
SMPS , UPS , USB, ASCII,CUI, GUI, CU , ENIAC , EDVAC , EDSAC ,

IC, SSI ,

VLSI, FDD , HDD

,
BIOS
,MICR,CD
-
RW

Q
46
.Write short notes
:

Hardware
,
Software
,

System

software
,
Application
software
,

Utilities
,
Compiler
,
Interpreter
,
Source program
,
Object program
,
Booting
,
Multiprogramming
,
Multiprocessing
,
Time sharing

Q
47

a) What is computer? What are the characteristics of Computers?







b
) One Terabyte
(TB) is equivalent to


1) 210 Bytes 2) 220 Bytes 3) 230 Bytes 4) None of these.


c
) What is difference between RAM and ROM?




d
) Define System Software and what are its two main types? Give examples.




e
)

Which of the
following are hardware and software?





(i) Transistor (ii) Internet Explorer (iii) Compiler (iv) FORTRAN




Q
48
.

a) What is the difference between Local Variable and Global Variable?




b) What is the difference b/w
“while”

&


do while
” loop?






c) What will be the size of following constants?
”Computer”, ’
\
”’


d) Write the corresponding C++ expressions for the following mathematical expressions:





i) ut+



ft
2

(ii) v
-
w/(a+b)
9


e) Evaluate the following, where a, b, c are integers and d, f are floating point numbers.


The value of a=16, b=4 and d=4.5
,

i)
f = a * b + a/b


ii)
c = d+a + b % a







Q
49
.
a) What is the output of the following?










i) # include<iostream.h>


void main ( )




{





int i=0;





for (i=1; i<=30;i++)





{





cout<<i<<endl;





i=i+2;






}

}


ii) # include<iostream.h>




void main( )




{




a=8;




a=a+6;




if (a>15)






cout<<a;





else





cout<<(a+9);



}











iii
) Determine the output:














f
or(i=10;i<=100;i+=10)


{


j=i/2;




cout<<j<<””;


}



Q
50
.
a) Find the error from the following code segment and rewrite the corrected code underlining the
correction made.




# include(iostream.h)


void Main ( );


int a,b;


cin>>a;


for(b=0,b<10,b++)


if a= =b


cout<<b+a;


else


cout>>a;


}




b) Convert the fo
llowing code segment into switch case construct.


int ch;


cin>>ch;


If(ch = = ‘A’)


{

cout<<“ Accountant”;


}


else If(ch = = ‘B’)



{



cout<<“Business Studies ”;




} else if(ch= =’C’)


{



cout<<“Computer Science”;


} else


{


cout<<“Invalid Choice”;




}



}


}

c) Convert the following code segment into do while loop.




#include<iostream.h>


void main()




{ int i;


for(i=1;i<=10;++i)




cout<<”
\
n”<<i;



}

Q
51
.

a) Write a C++ program to calculate the simple interest using function.





b
) 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.











Q
52
.
.

Explain the following terms: (Give answer any six)





i) Variable ii) Token
iii
) Debugging
i

v) Comment v) Keyword

Q
53
.
a
. Mention some of the application
s that use super computers.






b
. How is a compiler different from an interpreter.









c
. Give two major innovations in the s
econd generation computers?





Q53
.
a
. Mention the steps that you would foll
ow whi
le writing a program.






b
. What is the signif
icance of documentation?







Q
54
.
a
. What is wrong with the following statements?


1.const int y;

2. char ch=A; 3. long floa
t x; 4. cin>>a>>’
\
n’;






b
. What do you mean by
dynamic initialization of

a variable? Give an example








Q
55
. What will be the output for the following program segments?


(Consider all the necessary header files are included)








a. int a=5;















b=a++;


cout<<a++;


cout<<++b<<endl<<a+b;



b. int x=10,y=15;













float P;


P=(float) x/y;


cout<<P;


c. char p[]=”First
-
Semester

Examination2012”;








int i=4;


while (p[i]!= ‘ ’)



cout<<(p[i++]);


d. int x=0;
















for(int i=0;i<5;i++)


for(int j=0;j<I;j++)


x += i*j;


cout<<x;

Q56.

Convert the following as directed
:










1.


nested

If
-
else to switch statement


int x,y,z;


cin>>x>>y>>z;



if (x==1)


cout<<x*y+5;


else if (x==2)


cout<<x+2+y;


else if (x==3)


{ z=(x*y*5)/2;



cout<<z;}



else cout<<x<<’ ‘<<y<<’ ‘<<z;


2.
nested

while to nested for loop


i=5;


while(i>0)


{ k=1;



while (k<5)



{ cout<<k+I;



k+=2;}


cout<<endl;i++;


}


cout<<endl;

Q
57
.
Answer the following

:











a. Write a program to find the ticket fare of a bus according to the code of a bus.





code


fare



d


Rs.4



r



Rs.5



w


Rs.10



c


Rs.12