Jabalpur region study material computer science



Download 0.87 Mb.
Page1/7
Date conversion01.05.2018
Size0.87 Mb.
  1   2   3   4   5   6   7

KENDRIYA VIDYALAYA SANGATHAN

JABALPUR REGION

STUDY MATERIAL

COMPUTER SCIENCE

XII

(2010 Board Exam)

Patron

Smt. S. Bisarya

Assistant Commissioner

KVS RO Jabalpur Region


Guided By:

R. Radhakrishnan

PRINCIPAL

K.V. NARSINGHPUR


Prepared By:

Mr. Sanatan Banji

PGT Computer Science

K.V. NARSINGHPUR.





How to use Study Material:

  • It will be much beneficial to those students who need special care and attention. I am sure, thorough study and practicing similar patterns of questions of this material will help such students secure 60% and above.

  • However it is not 100% substitute for Textbook.

  • Minimum a set of five questions with answers from each questions of the Board Pattern Question Paper are included, keeping in mind the needs and interest of target group.

  • Concepts in every unit have been explained using notes / solutions to questions / guidelines in a simple language.

  • Practice and peer group discussion on this study material will definitely improve the confidence level of the students when they solve the questions.

  • Now you are welcome to the ... content ...

Sanatan Banji

PGT Computer Science

KV Narsinghpur


Weightage to different topics/content units


S. No

UNIT

VSA

1 Mark


SA I

2 Marks


SA II

3 Marks


LA

4 Marks


Total

1

Review of C++ covered in Class XI

1 (1)

8 (4)

3 (1)




12 (6)

2

Object Oriented Programming in C++

a) Introduction to OOP using C++

b) Constructor & Destructor

c) Inheritance





2 (1)


2 (1)



4 (1)
4 (1)


6 (2)


2 (1)

4 (1)


3

Data Structure & Pointers

a) Address Calculation

b) Static Allocation of Objects

c) Dynamic Allocation of Objects

d) Infix & Postfix Expressions



2 (1)

2 (1)


3 (1)


3 (1)

4 (1)

3 (1)

5 (2)


4 (1)

2 (1)


4

Data File Handling in C++

a) Fundamentals of File Handling

b) Text File

c) Binary Files


1 (1)


2 (1)

3(1)




1 (1)


2 (1)

3 (1)


5

Databases and SQL

a) Database Concepts

b) Structured Query Language




2 (1)


2 (1)




4 (1)

2 (1)

6 (2)


6

Boolean Algebra

a) Introduction to Boolean Algebra & Laws

b) SOP & POS

c) Karnaugh Map

d) Basic Logic Gates


1 (1)

2 (1)

2 (1)



3 (1)



2 (1)


1 (1)

3 (1)


2 (1)

7

Communication & Open Source Concepts

a) Introduction to Networking

b) Media, Devices, Topologies & Protocols

c) Security

d) Webservers

e) Open Source Terminologies


2 (2)
2 (2)

1 (1)

1 (1)







4 (1)

2 (2)

4 (1)


2 (2)

1 (1)


1 (1)

TOTAL

9 (9)

26 (13)

15 (5)

20 (5)

70 (32)


Review of C++ covered in Class XI
Questions based on Header Files

Very Short Answer Questions ( 1 mark)
Q1. Write the names of the header files to which the following belong:

(i) isdigit() (ii) strcmp() (iii) fabs() (iv) gets() (v) eof()

(vi) setw() (vii) exit() (viii) tolower() (ix) ceil() (x) feof()

(xi) strupr() (xii) atoi() (xiii) setprecision() (xiv) floor() (xv) remove()

(xvi) strstr() (xvii) put() (xviii) puts() (xix) exp() (xx) free()

(xxi) fwrite() (xxii) write() (xxiii) setiosflags() (xxiv) sin() (xxv) abs()


Ans : (i) ctype.h (ii) string.h (iii) math.h (iv) stdio.h (v) iostream.h

(vi) iomanip.h (vii) process.h (viii) ctype.h (ix) math.h (x) stdio.h

(xi) string.h (xii) stdlib.h (xiii) iomanip.h (xiv) math.h (xv) stdio.h

(xvi) string.h (xvii) iostream.h (xviii) stdio.h (xix) math.h (xx) stdlib.h

(xxi) stdio.h (xxii) iostream.h (xxiii) iomanip.h (xxiv) math.h (xxv) stdlib.h /

math.h


Q2. Name the header file(s) that shall be needed for successful compilation of the following C++ code:

void main( )

{

char subject[30];



strcpy(subject, ”Computer Science”);

puts(subject);

}

A


Note: Marks are not to be deducted if any additional header file is mentioned. But these header files must be written.

ns : string.h

stdio.h
Q3. Name the header file(s) that shall be needed for successful compilation of the following C++ code:

void main( )

{

char name[20];


gets(name);

cout<

}

Ans : iomanip.h


stdio.h
Q4. Name the header file(s) that shall be needed for successful compilation of the following C++ code:

void main( )

{

char a, b;



a = getchar();

b = toupper(a)

cout<<”\nThe uppercase character of “<< a <<” is “ <

}

Ans : ctype.h



stdio.h
Q5. Name the header file(s) that shall be needed for successful compilation of the following C++ code:

void main( )

{

char num[]="1024";



cout<<"\nThe next number to "<< num <<" is " <

cout<<"\nThe square root of "<

}

Ans : stdlib.h



math.h
Concept Questions based on C++ Review

Short Answer Questions ( 2 marks)
Q1. What is the difference between a keyword and an identifier in C++? Give examples of both.

Ans : Keyword is a special word that has a special meaning and purpose. Keywords are reserved and are few. For example: goto, for, while, if, else etc.

Identifiers are the user-defined name given to a part of a program. Identifiers are not reserved. It should be the name of any keyword. For example: name, stud, _myfile, op etc.
Q2. What is a reference variable? What is its usage?

Ans : A reference variable is an alias name for a previously defined variable. The usage of it is that the same data object can be referred to by two names and these names can be used interchangeably.

Q3. Write two advantages of using include compiler directives.

Ans: (i) The #include compiler directive lets us include desired header files in our program which enables us work with all declaration / definitions / macros inside the included header file(s).

(ii) It supports modularity.

Q4. Differentiate between a Logical Error and Syntax Error. Also give suitable examples of each in C++.

Ans : Logical Error: Error occurred due to incorrect logic applied by the programmer.

Syntax Error: Error occurred due to not following the proper grammar/syntax of the language OR the error occurred due to violating rules of the programming language

Example:

//Program to find area and perimeter of rectangle

void main()

{

int A=10, B=20, AR, P;



AR=2*(A*B); //Logical Error – Wrong Formula

P=2*(A+B);

cout<>endl; //Syntax Error – Use of >> with cout

}
Q5. What is the difference between Global Variable and Local Variable?


Ans:

Global Variable

Local Variable

  • It is a variable, which is declared outside all the functions

  • It is accessible throughout the program.

  • It is a variable, which is declared with in a function or with in a compound statement

  • It is accessible only within a function/ compound statement in which it is declared.

#include

float NUM=900; //NUM is a global variable

void LOCAL(int T)

{

int Total=0; //Total is a local variable



for (int I=0;I

Total+=I;

cout<

}

void main()



{

LOCAL(45);

}

Q6. What is the difference between Object Oriented Programming and Procedural Programming?

Ans :


Object Oriented Programming

Procedural Programming

  • Emphasis on Data

  • Follows Bottom-Up approach in program design

  • Data hiding feature prevents accidental change in data

  • Features like data encapsulation, polymorphism, inheritance are present

  • Emphasis on doing things (functions)

  • Follows Top-down approach in program design

  • Presence of Global variables increase chances of accidental change in data

  • Such features are not available

Q7. Differentiate between a Call by Value and Call by Reference, giving suitable examples of each?

Ans:


Call by Value

Call by Reference

  • The called function creates its own copies of the original values sent to it.

  • Any changes that are made in the function run, changes in the original values are not reflected.

  • The called function accesses and works with the original values using their references.

  • Any changes that occur in the function run, changes in the original values are reflected.

void change(int b)

{

b = 10;


}

void main()

{

int a = 5;


cout<<”\n a = “<

change(a);

cout<<”\n a = “<

}

Output will be: a = 5



a = 5

void change(int &b)

{

b = 10;



}

void main()

{

int a = 5;



cout<<”\n a = “<

change(a);

cout<<”\n a = “<

}

Output will be: a = 5



a = 10

Q8. What is a parameter? Differentiate between an actual and a formal parameter with an example?

Ans : Parameter is the variable / value passed to a function or the variable that is used as the incoming values in a function. The variables / values passed to a function are called actual parameters. The variables that are used as the incoming values in a function are called formal parameters. For Example:

void change(int b) // b is the formal parameter

{

b = 10;


}

void main()

{

int a = 5;



change(a); // a is the actual parameter

cout<<”\n a = “<

}
Q9. Enlist any four jump statements with their uses.

Ans : (i) goto : A goto statement can transfer the program control anywhere in the program.

(ii) break : A break statement enables a program to terminate of the loop/block, skipping any code in between.

(iii) continue : A break statement enables a program to force the next iteration to take place, skipping any code in between.

(iv) return : A return statement is used to return from a function.

Q10. How are the following related to one another?

(i) array and structure (ii) structure and class

Ans: (i) Array is a group of items of the same data types whereas structure brings together a group of related data items of any data types.

(ii) Structure is actually a class (in C++) declared with keyword struct. By default, all members are public in a structure; on the other hand all members are private by default in a class.


Questions based on Program Errors

Short Answer Questions ( 2 marks)

Note : Errors are explained in the solutions. While solving such type of question, a student should carefully go through correctness of each statement and the logic of the whole program. Students are advised to practice various questions to develop the skill of finding the errors.


Q1. Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include

int func(int y =10, int &x)

{

if(x%y = 0) return ++x ; else return y-- ;



}

void main()

{

int p = 20, q = 23;



r = func(p,q);

cout>>p>>q>>r;

}

Ans: #include



int func(int y , int &x) // violating the rule of Default argument

{

if(x%y = = 0) return ++x ; else return y-- ; // = = relational operator



}

void main()

{

int p = 20, q = 23;



int r = func(p,q); // r should be declared

cout << p << q << r; // << operator for cout

}

Q2. . Rewrite the following program after removing the syntactical errors (if any). Underline each correction.



#include

void main()

{

int X[ ]={60,50,30,40},Y; count=4;



cin>>Y;

for(i=count-1;i>=0;i--)

switch(i)

{

case 1;


case 2: cout<

case 3: cout<

}

}


Ans: #include



void main()

{

int X[ ]={60,50,30,40},Y, count=4; // multiple declaration separated by comma



cin>>Y;

for(int i=count-1; i>=0; i--) // i should be declared

switch(i)

{

case 1:; // case should follow by :

case 2: cout<; break; // Lvalue required for X

case 3: cout<

}

}

Q3. Rewrite the following program underlining the syntactical errors (if any) and its explanations.



#include

void main()

{ int n = 44;

int *ptr = &n;

++(*ptr);

int *const cptr = &n;

++(*cptr);

++cptr;


const int kn=88;

const int *ptrc = &kn;

++(*ptrc);

++ptrc;


const int *const cptrc =&kn;

++(*cptrc);

++cptrc;

}

Ans: #include



void main()

{ int n = 44;

int *ptr = &n;

++(*ptr);

int *const cptr = &n;

++(*cptr); //cannot modify the constant value of *cptr

++cptr;


const int kn=88;

const int *ptrc = &kn;



++(*ptrc); //cannot modify the constant value of *ptrc

++ptrc;


const int *const cptrc =&kn;

++(*cptrc); //cannot modify the constant value of *cptrc

++cptrc; //cannot change the constant address of cptrc

}

Q4. Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include

struct Pixels

{ int Color,Style;}

void ShowPoint(Pixels P)

{ cout<

void main()



{

Pixels Point1=(5,3);

ShowPoint(Point1);

Pixels Point2=Point1;

Color.Point1+=2;

ShowPoint(Point2);

}

Ans: #include



struct Pixels

{ int Color,Style;} ; // Definition of structure Pixels must be ended with ;

void ShowPoint(Pixels P)

{ cout<
<<
P.Style<

void main()

{

Pixels Point1 = {5,3}; // { } to be used to initialise of members of the object



ShowPoint(Point1);

Pixels Point2=Point1;



Point1.Color+=2; // member to followed by the object using . operator

ShowPoint(Point2);

}
Q5. Rewrite the following program after removing the syntactical errors (if any). Underline each correction.

#include

class sum

{

int x, y, total;



public :

sum(int a, b)

{

x=a ; y = b * 2 ; total = 0 ;



}

void display()

{

c = x + y ;



total += c ;

cout << total ;

}

}

void main()


{

sum s(20, 10);

display();

}

Ans : #include


class sum

{

int x, y, total;



public :

sum(int a, int b) // argument b should be declared separately

{

x=a ; y = b * 2 ; total = 0 ;



}

void display()

{

int c = x + y ; // local variable c should be defined



total += c ;

cout << total ;

}

}; // class definition must terminate with ;

void main()

{

sum s(20, 10);



s.display(); // member function must be invoked using . operator

}
Questions based on Finding Outputs using random()



Short Answer Questions ( 2 marks)

Note: random(n) generates the numbers randomly from 0 to n–1. For example: random(20) generates randomly from 0 to 19. Explanations are given at the end of each solution.

Q1. In the following program, if the value of N given by the user is 50, what maximum and minimum values the program could possibly display?

#include

#include

void main()

{

int N,Guessme;



randomize();

cin>>N;


Guessme=random(N) + 5;

cout<

}
Ans : Minimum : 5 Maximum : 54

Explanation : Since random(50) gives a number randomly from 0 to 49. If it returns 0 i.e. minimum for random(50), the minimum value for Guessme will be 0 + 5 = 5. If it returns 49 i.e. maximum for random(50), the maximum value for Guessme will be 49 + 5 = 54.

Q2. In the following program, write the correct possible output(s) from the options (i) to (iv).

#include

#include

void main( )

{

randomize( );


char City[ ][10]={“DEL”,”CHN”,”KOL”,”BOM”,”BNG”};

int Fly;

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

{

Fly=random(2) + 1;



cout<

}

}



Outputs:

(i) DEL : CHN : KOL:

(ii) CHN: KOL : CHN:

(iii) KOL : BOM : BNG:



  1. KOL : CHN : KOL:

Ans : So the possible output will be (ii) CHN : KOL : CHN: and (iv) KOL :CHN : KOL:

Explanation : Since random(2) gives either 0 or 1, Fly value will be either 1 or 2.

City[1] is “CHN” and City[2] is “KOL” . Since I value from 0 to 2 (<3), 3 iterations will takes place. So the possible output consists 3 strings separated by :, each of them may be either “CHN” or “KOL”.

Q3. Study the following program and select the possible output from it:

#include

#include

const int Max=3;

void main( )

{

randomize();



int Number;

Number=50 + random(Max);

for(int P=Number; P >=50; P - -)

cout<


c
Explanation : Since random(3) gives a number randomly from 0 to 2. So, the values of Number ranges from 50 (50+0) to 52 (50+2) and the Number should be displayed in descending order according to the programme. 53 is not possible, so the answer is (iv).
out<}

  1. 53#52#51#50#

  2. 50#51#52#

  3. 50#51#
  4. 51#50#


Ans: 51#50#

Q4. 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)?

#include

#include

void main()

{

int Guess;



randomize();

cin>>Guess;

for (int I=1;I<=4;I++)

{ New=Guess+random(I);

cout<<(char)New;

}


Explanation : In first iteration I = 1 and random(I) gives 0. So, New = 65 + 0, hence output is A. In first iteration I = 1, So, New = 65 + 0, hence output is A. In second iteration I = 2 and random(I) gives 0 or 1. So, New = 65 or 66, hence output is A or B. In third iteration I=3 and random(I) gives 0 to 2. So, New = 65 or 66 or 67, hence output is A or B or C. In fourth iteration I=4 and random(I) gives 0 to 3. So, New = 65 or 66 or 67 or 68, hence output is A or B or C or D. Option (i) satisfies all the above only, so it is the answer.

}

(i) ABBC



(ii) ACBA

(iii) BCDA

(iv) CABD
Ans: (i) ABBC
Q5. 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?

#include

#include

void main()

{

int N,Guessnum;



randomize();

cin>>N;


Guessnum= random(N – 10)+10;

cout<

}

Ans : Maximum Value: 19 Minimum Value: 10


Questions based on Finding Outputs

Short Answer Questions ( 2 marks)

Note : While solving such type of question, a student should carefully go through the logic of the whole program and concepts used in it. Various patterns of questions are given below. Students are advised to practice various questions to develop the skill of finding the output.



Q1. Find the output of the following program:

#include

struct Game

{

char Magic[20];int Score;



};

void main()

{

Game M={“Tiger”,500};



char *Choice;

Choice=M.Magic;

Choice[4]=’P’;

Choice[2]=’L’;

M.Score+=50;

cout<

Game N=M;

N.Magic[0]=’A’;N.Magic[3]=’J’;

N.Score-=120;

cout<

}




  1   2   3   4   5   6   7


The database is protected by copyright ©hestories.info 2017
send message

    Main page