7
HOLIDAY HOMEWORK 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 “; 1

Holiday Home Work Class Xi -2014

  • Upload
    anushka

  • View
    219

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Holiday Home Work Class Xi -2014

HOLIDAY HOMEWORK 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 thricevar1= 1; var2 = 11;

{ cout << var1++ << “ “ << -- var2 << “\n “ ;

cout << var2-- << “ “ << var1++ << “\n” ;}

7) What is the difference b/w instruction , program and software? 8) (i) Storage of 1 KB means the following number of bytes : 1) 1000 2) 964 3) 1042 4) 1024

1

Page 2: Holiday Home Work Class Xi -2014

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.

II 1) What is the difference b/w if – else - if and switch - case

2) What are data types? What are all predefined data types in c++? 3) Write the corresponding C++ expressions for the following mathematical expressions:

i) √ (a2+b2+c2) (ii) p+q/(r+s) 4

4) Evaluate the following, where a, b, c are integers and d, f are floating point numbers. The value of a=8, b=4 and d=2.5

(i) f = a * b + a/b(ii) c = d+a + b % a

5) Write the output 1) # include<iostream.h> void main( ) { a=3; a=a+1; if (a>5) cout<<a; else cout<<(a+5);

} 2) What will be the output of the following program segment? If input is as: (a) c (b) m (c) a (d) v cin >>ch; switch (ch) { case ‘c’: cout<<”Computer Science”; case ‘m’: cout<<”Mathematics”; break; case ‘a’: cout<<”Accoutant”; break; default: cout<<” wrong choice”; }

3) What output will be the following code fragment produce? void main( )

2

Page 3: Holiday Home Work Class Xi -2014

{ 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

4) 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”;

}}

}

5) Given the following code fragment int ch=65; cout << ++ch<< “\n”<<ch<<”\n”;

i) What output does the above code fragment produce?ii) What is the effect of replacing ++ ch with ch+1?

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.

3

Page 4: Holiday Home Work Class Xi -2014

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

4 Explain the following term:

i) Variable ii) Token iii) comment iv) Keyword

5) Convert the following hex numbers to decimal i) E9 ii) 7 CA3

6) convert the following number to decimal 111011 . 11117) Write a program that reads the units in feets and converts into its equivalent meter and centimeter.

8) Write a program to enter the marks in 5 subjects and calculate the percentage obtained

9) . Write a program to find the smallest of any given three numbers without using logical and operator

10). What is the role of compiler apart from pointing out errors.

11. What does C++ have data type modifiers ?

12. An electricity board charges according to following rates For the first 100 units - 40 P per unitFor the next 200 units - 50 P per unitBeyond 300 units - 60 P per unitAll users are charged meter charge also which is Rs. 50 / - .

13. Evaluate the following C++ expression where a , b, c are integers and d, f, are floating point numbers . The value of a= 5 , b = 3, and d = 15

a) . f = a + b /a

4

Page 5: Holiday Home Work Class Xi -2014

b) c = d * a +bc) c = (a++) * d + ad) f = ( ++b) * b - ae) 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.

Submitted by: Mr. Saju . B . Pillai (PGT Computer Science)-

5