21
[1] AIR FORCE SCHOOLS Class XII (2017-2018) Marking Scheme - COMPUTER SCIENCE (083) MM : 70 Time Allowed: 3 hours 1. (a) Write the names of header files, which are necessary to run the following program: #include<iostream.h> void main() { float numbers[]={555.456,34.123,7.19}; inti,j; for (i = 0; i<3; i++) { j=floor(numbers[i]); cout<<setw(6)<<j; } } (1) Ans: iomanip.h, math.h ( ½ x 2 = 1 Mark for correct header file names) Note: deduct ½ Mark if an extra header file name is mentioned. (b)How is an alias of a variable and an alias of a data type created? Explain with suitable examples. (2) Ans: Alias of a variable, also known as a reference variable is created by using &. Example: int y; int x=&y; Alias of a data type is created using typedef keyword Example: typedef char grade; (1 mark for explaining the difference between typecasting and typeconversion) ( ½ mark each for corresponding correct example) (c) Rewrite the following C++ code after removing all the syntax error(s) if present in the code, also underline each correction: #include <iostream.h> (2)

AIR FORCE SCHOOLS Class XII (2017-2018) Marking …... Convert the following infix expression into its postfix form showing ... Expression: - a + b * c ^ ( d * e ... the corresponding

Embed Size (px)

Citation preview

[1]

AIR FORCE SCHOOLS

Class XII (2017-2018)

Marking Scheme - COMPUTER SCIENCE (083)

MM : 70 Time Allowed: 3 hours

1. (a) Write the names of header files, which are necessary to run the following program:

#include<iostream.h> void main() { float numbers[]={555.456,34.123,7.19}; inti,j; for (i = 0; i<3; i++) { j=floor(numbers[i]); cout<<setw(6)<<j; } }

(1)

Ans:

iomanip.h, math.h

( ½ x 2 = 1 Mark for correct header file names)

Note: deduct ½ Mark if an extra header file name is mentioned.

(b)How is an alias of a variable and an alias of a data type created? Explain with suitable

examples.

(2)

Ans:

Alias of a variable, also known as a reference variable is created by using &.

Example: int y; int x=&y; Alias of a data type is created using typedef keyword Example:

typedef char grade;

(1 mark for explaining the difference between typecasting and typeconversion)

( ½ mark each for corresponding correct example)

(c) Rewrite the following C++ code after removing all the syntax error(s) if present in the code, also underline each correction:

#include <iostream.h>

(2)

[2]

#include<string.h>

class Compile

{

int a=10; char error[20]=”ERROR”;

public:

void A() { cin>>a; gets(error);}

void B() { cout<<a<<”\T”<<b;};}

void main() { Compile E; E.B(); E.A(); E.B(); }

Ans:

#include <iostream.h>

#include <stdio.h> ( ½ mark)

#include <string.h>

class Compile

{

int a; char error[20];

public:

Compile() { a=10; strcpy(b,”error”);} ( 1 mark)

void A() { cin>>a; gets(error);}

void B() { cout<<a<<”\T”<<b};

}; ( ½ mark)

void main() { Compile E; E.B(); E.A(); E.B(); }

(d)Find output of the following program segment:

#include<iostream.h>

#include<conio.h>

void main()

{

intarr[]={5,2,7,9,3,5,6};

int *p=arr,i;

i=arr[3]-arr[2];

cout<<++*(p+i)<<'@';

cout<<*p++<<'@'<<i<<'\n';

for(;i>=0;i-=2)

cout<<++arr[i]<<'#';

getch();

}

(2)

Ans:

8@5@2 9#6#

[3]

(1 Mark for first correct line of output

1 mark for the second lines of output)

Note:Deduct ½ Mark each for any 2 wrong values

(e) Find output of the following program segment:

#include<iostream.h> #include<conio.h> class Effort { ints,points; char level; public: Effort(int x) {s=points=0;level=’z’;} Effort(char gg='B') { points=4;s=1;level=gg;} void trial(intss) { s+=ss; if(s>=100) points=6; else if(s>=50) points=4; else points=1; } void find_level() { level=(level=='B')?'A':'C'; } void display() { cout<<level<<'@'<<points<<'\n'; cout<<s<<'\n'; } }; void main() { Effort a(10),b('C'); a.display(); b.trial(75); b.find_level(); a.trial(130); b.display(); a.display(); getch(); }

(3)

Ans:

[4]

z@10 10 c@4 76 z@6 140

( ½ Mark for each correct line of output)

Note:Deduct ½ Mark if the output is not shown in 3 separate lines

(f) Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it.

Justify your answer.

Note: Assume all the required header files are already being included in the code.

void main() { randomize(); intVALUE; VALUE=random(3); char TOWN*+*25+=,”PATNA”,”MUMBAI”,”KOLKATA” ,”CHENNAI”-; for(intA=0;A<=VALUE;A++) { for(intB=0;B<=A;B++) cout<<TOWN[B]; cout<<endl; }}

(i) PATNA

PATNAMUMBAI

PATNAMUMBAIKOLKATA

(ii) MUMBAI

MUMBAIKOLKATA

MUMBAIKOLKATACHENNAI

(iii) PATNA

PATNAMUMBAI

PATNAMUMBAIKOLKATA

PATNAMUMBAIKOLKATACHENNAI

(2)

[5]

(iv) KOLKATA

KOLKATACHENNAI

Ans:(i)PATNA

PATNAMUMBAI

PATNAMUMBAIKOLKATA

(1 Mark for mentioning correct option)

(1 mark for justification)

Note: No Mark to be awarded for writing any one additional optionwith (i) .

2. (a)What is Inheritance? How does it differ from Containership? Explain with suitable example (2)

Ans:It is the capability of a class to inherit the properties from another class. Inheritance lets you create or define specialized instance of a class that shares the properties of the class and at the same time adds new features to it by implementing reusability of the code. When a class contains objects of another class as its members then it is referred to as a containership. It implements has a relationship.

( ½ mark each for inheritance & containership definition

½ mark each for examples)

(b) Observe the following C++ code and answer the questions (i) and (ii). Assume allnecessary files are

included:

class FICTION { public: long FCode; char FTitle[20]; float FPrice; FICTION() //Member Function 1 { cout<<”Bought”<<endl; FCode=100;strcpy(FTitle,”Noname”);FPrice=50; } FICTION(intC,char T[],float P) //Member Function 2 { FCode=C; strcpy(FTitle,T); FPrice=P;} void Increase(float P) //Member Function 3 {FPrice+=P;}

(2)

[6]

void Show() //Member Function 4 {cout<<FCode<<”:”<<FTitle<<”:”<<FPrice<<endl;} ~FICTION() //Member Function 5 {cout<<”Fiction removed!”<<end1;} void main() //Line 1 { //Line 2 FICTION F1,F2(101,”Dare”,75); //Line 3 for (int I=0;I<4;I++) //Line 4 { //Line 5 F1.Increase(20);F2.Increase(15); //Line 6 F1.Show();F2.Show(); //Line 7 } //Line 8 } //Line 9

(i) Which specific concept of object oriented programming is illustrated by Member Function 1 and

Member Function 2 combined together?

Ans:

Polymorphism

(1Mark for mentioning the correct concept name )

(ii) How many times the message ”Fiction removed!” will be displayed afterexecuting the above C++ code?

Out of Line 1 to Line 9, which line is responsible todisplay the message ”Fiction removed!”?

Ans: 2 times , Line 9

( 1⁄2 Mark for writing correct number of times)

( 1⁄2 Mark for writing correct line number)

(c) Define a class Movie in C++ with following description:

Private members:

Title- of type string

Genre- of type string

Cost- of type long int

YearOfRelease- of type int

Function Cost_per_print(int) – to take a parameter n and return cost per print.

Cost per print should be calculated as Cost/n + 5.

Public Members:

(4)

[7]

Read_Data() to read an object of Movie type.

Display() to display the details of an object of Movie type along with Cost per

print. To display cost per print the function Display() should input n and make

call to the function Cost_per_print().

RetRelease() to return the value of YearOfRelease of an object of Movie type.

Ans:

class Movie { char Title[30], Genre[20]; long int Cost; intYearOfRelease; float Cost_per_print(int n) {return Cost/5.0 + n;} public: void ReadData() { cout<<"Enter Title: "; gets(Title); cout<<"Enter Genre: "; gets(Genre); cout<<"Enter Cost: "; cin>>Cost; cout<<"Enter Year of Release: "; cin>>YearOfRelease; } void Display() { cout<<"\nTitle: "<<Title; cout<<"\nGenre: "<<Genre; cout<<"\nCost: "<<Cost; cout<<"\nEnter number of prints: "; cin>>n; cout<<"\nCost per print: "<<Cost_per_print(n); cout<<"\nYear of release: "<<YearOfRelease; } intRetRelease() { return YearOfRelease;} };

(½ Mark for correct syntax for class header)

(½ Mark for correct declarations of data members)

(1 Mark each for appropriate definition of function members)

Note:

Deduct ½ Mark if there are more than 1 syntax errors

Deduct ½ Mark if keyword public is not used

(d) Consider the following and answer the questions given below:

class School

(4)

[8]

{ char sname[30];

protected:

long code;

public:

char address[50];

void INPUT();

void OUTPUT();

};

class Dept: protected School

{ char dname[20];

protected:

float sal; void IN();

public:

int a; void OUT();

};

class Teacher: public Dept

{ char tname[25],subject[10];

void DISPLAY(void);

public:

void ENTER();

};

1. How much of memory space will be occupied by the object of Dept and Teacher? 2. Name the data members that can be accessed by function OUT(). 3. Which type of inheritance is shown in the above code? 4. Name the members accessible by the objects of class Teacher?

Ans:

1. 110 , 145 2. Dname[20], sal, a,code,address 3. Multilevel 4. a, enter(),out()

(1 mark for each correct answer)

3. (a) Write function definition for SCOUNT(char S[]) in C++ which returns the number of

words present in the string S (passed as parameter) which start with the alphabet S or s.

For example if the following string is passed to the function:

“She sells sea Shells on the sea shore. “

Then the function should return 6, which is the number of words starting with S or s.

(3)

Ans:

int SCOUNT(char S[]) { int count=0; for(inti=0; S[i+!=’\0’; i++) { if(S*i+==’ ‘) , if(S*i+1+==’S’ ||S*i+1+==’s’) count++; } return count;

[9]

} (½ Mark for correctly writing the function header with arguments)

( ½ Mark for correct variable declaration and initialization of count)

( ½ Mark for correct loop)

( 1 Mark for correct if statement)

( ½ Mark for correctly returning the value)

Note:Deduct ½ Mark if there are more than 1 syntax errors

(b) An array SUGAR[30][10] containing long integers is stored in the memory. If the base address

of SUGAR is 2000, find out memory locations of SUGAR[12][8] , if the content is stored along

the row.

(2)

Ans:

Given, W=4 R=30 C=10 Base Address (B) = 2000 Row Major Formula: Address(A[I][J]) =B + W*(I*C+J) => Address (A[12][8]) = 2000 + 4*(12*10+8) = 2000 + 4*128 = 2000+ 512 = 2512

(1 Mark for writing correct formula (for row major) OR substituting formula with correct values) (1 Mark for correct calculation of address of A[12][8])

(c) Consider the program segment below. Write the function definition of Delete () to delete an

element and also returns the element being deleted from the queue.

struct My_Node { int element; My_Node *link; }; class My_Queue { My_Node *F, *R; public: My_Queue() { F = R = NULL;} void Insert( int ); int Delete(); };

(2)

[10]

Ans:

void Queue::Delete() { Node *N ; int no; if (F == NULL) cout<<"Underflow error..."; else { N = F; F=F->link; no=N->element; delete(N); } return no; }

(½ Mark for underflow error)

(½ Mark for correctly returning the element value)

(½Mark for correctly modifying the pointers)

(½Mark for de-allocating memory space)

Deduct ½ mark each for 2 errors.

(d)Consider the following global declaration of a stack:

char cities[20][30];

Write a function to push an element onto the stack containing list of names of cities. The

name of the city to be pushed on the stack and the position of the topmost element of the

stack is passed as argument to the function.

Also display the elements of the stack after insertion.

(2)

Ans:

void Push_city( char name[], int top) { { if (top==19) cout<<”\n overflow”; else strcpy(cities[++top],x); } for(int i=0; i<20;i++) puts(cities[i]); }

( ½ mark for correct function header with arguments

( ½ each for correct push statement with if construct )

(1 mark for correct display statements

[11]

( deduct ½ mark each for 2 main errors)

(e) Convert the following infix expression into its postfix form showing stack status as every step:

- a + b * c ^ ( d * e ) / f

(2)

Ans:

Expression: - a + b * c ^ ( d * e ) / f

Symbol Scanned Operator Stack Postfix expression

(

- (-

A (- a

+ (+ a,-

B (+ a,-,b

* (+ * a,-,b

C (+ * a,-,b,c

^ (+ * ^ a,-,b,c

( ( +* ^ ( a,-,b,c

D ( +* ^ ( a,-,b,c,d

* ( +* ^ (* a,-,b,c,d

E ( +* ^ (* a,-,b,c,d,e

) ( +* ^ a,-,b,c,d,e,*

/ ( + / a,-,b,c,d,e,*,^,*

F (+ / a,-,b,c,d,e,*,^,*,f

) a,-,b,c,d,e,*,^,*,f,/,+

Therefore, the corresponding postfix expression is: a,-,b,c,d,e,*,^,*,f,/,+

( ½ Mark each for correctly reaching the points 1, 2, 3, 4)

1

2

3

4

[12]

(f) What are dynamic memory allocation operators in C++? Explain with example.

In c++ dynamic memory allocation operators allocate/deallocate memory from the free store. They are :

“new” operator : This operator can be used to allocate the memory dynamically. For ex. :-

int *a = new int;

“delete” operator : When an object created by ‘new’ is no longer required, it must be destroyed so that the

memory space occupied by it may be released for re-use. This can be done by ‘delete’ operator.

For ex. delete a ;

(1 mark for correct definition)

(1 mark for correct example)

(2)

4. (a) A binary file “Bookstore.dat” contains data of 20 books. The data of each book is an object of

the following class:

class Book { int book_id;char Title[10];float price; public: void EnterData() {cin>>book_id; cin.getline(Title,20);cin>>price; } void ShowData() {cout<<book_id<<” - ”<<Title<<endl;cout<<price;} };

What will be the output of the following code segment, assuming that all the required header

files are already included in the program.

ifstream File; Book B; File.open(“LIBRARY.DAT”,ios::binary|ios::in); File.seekg(0, ios::end); cout<<File.tellg();

(1)

Ans:

320

( 1 Mark for correct answer)

(b) Consider the following class declaration:

class Account_details { int accno; char name[25];

(3)

[13]

float balance; public: void input() {cin>>accno>>balance; gets(name);} void display(),cout<<accno<<” “<<name<<” “<<balance<<endl;- void deposit(float amt) { balance+=amt; } int getact( ){ return accno; }};

The binary file “bank.dat” stores the details of customers from the bank. Write a function in

C++ to update the details of a customer for a given account number who deposited a given

amount in his account. (Note: Do not use any temporary file.)

Ans:

void update() { fstream F; F.open(“bank.dat”,ios::binary|ios::ate); Account_detailsAD;intano; float amt; cout<<”\n enter account number & amount:”; cin>>ano>>amt; F.seekg(0,ios::beg); while (F.read((char*)&AD,sizeof(AD))) { if (AD.getact()== ano) { F.seekg(F.tellg()- sizeof(AD), ios::beg); AD.deposit(amt); F.write((char*)&AD,sizeof(AD)) } } FIL.close(); }

(½ Mark for opening bank.dat correctly)

(½ Mark for reading each record from the file)

((½ Mark for getting account number and amount and passing as parameters)

(½ Mark for checking account number)

(½ Mark for seeking pointer back to the record)

(½ Mark for updating object for amount deposition and writing back to file)

* deduct ½ mark each for two main errors

(c) Write a function in C++ to display the lines starting with a capital alphabet from a text file

“MyFile.TXT” page by page. Assume that no line in the file is more than 80 characters long and

not more than 10 lines are displayed on the screen at a time.

(2)

[14]

Ans:

void LineCount() { ifstream F; F.open(“MyFile.TXT”, ios::in); char Line[81]; int Count = 0; while(!F.eof()) { F.getline(Line,80); if (isupper(Line[0])) Count++; if(Count %10==0) { getch(); clrscr(); } } F.close(); }

(½ Mark for opening text file correctly&for correct loop for reading lines from file)

(½ Mark for correctly reading lines from file)

(½ Mark for correctly checking the condition and incrementing the counter)

(½ Mark for page break display)

(d) Which type of file (text or binary) is faster in processing data? Why?

Ans: Binary file Because no conversions take place as data is saved in the form of 0s and 1s ( ½ Mark for correct answer and ½ mark for correct reason)

1

5. (a) Explain the term candidate key and alternate key giving examples. (2)

Ans: The field in the table which has all the properties of becoming the primary key are the candidate keys. Out of the candidate keys, one becomes the primary key. The rest are alternate keys. (any suitable example) ( ½ mark each for correct definition

½ mark each for correct example)

(b)Study the following tables DEPT and WORKER and write SQL commands for the questions (i) to (v) and

give output for SQL commands (vi) and (vii). (Give the output based on the data given in the table.)

[15]

TABLE : DEPT

DCODE DEPARTMENT CITY

D01 Media Delhi

D02 Marketing Delhi

D03 Infrastructure Mumbai

D04 HR Mumbai

D05 Finance Kolkata

(i) Display the worker number, name for workers who joined before 2014-01-01 in descending order of worker number. Ans: SELECT WNO, NAME FROM WORKER WHERE DOJ<’2014-01-01’ ORDER BY WNO DESC

(ii) Display the Department code and the number of workers in that department code. Ans: SELECT DCODE, COUNT(WNO) FROM WORKER GROUP BY DCODE

(iii) Display the worker name and the department (name of the department in which the worker is working. SELECT NAME, DEPARTMENT FROM DEPT, WORKER WHERE DEPT.DCODE=WORKER.DCODE

(iv) Change the city to Noida for all departments where department name starts with ‘M’. UPDATE DEPT SET CITY=’Noida’ WHERE DEPARTMENT LIKE “M%”

(v) Insert a new row in DEPT table with values “D05”, “HOUSEKEEPING”, “AGRA”

(1)

(1)

(1)

(1)

[16]

INSERT INTO DEPT VALUES (“D05”,”HOUSEKEEPING”,”AGRA”) ( 1 mark for each correct query for (i) to (v) above)

(vi) Select max(DOJ), min(DOB) from WORKER; 2014-06-09 1984-10-19

(vii) Select NAME from WORKER, DEPT where WORKER.DCODE=DEPT.DCODE and CITY in (“MUMBAI”, “KOLKATA”); Anil Jha Mohitesh Jaya priya ( ½ mark for each correct output for (vi) and (vii))

(1)

½

½

6. (a) Verify the following algebraically:

X’Y+ X.Y’ = (X’+Y’).(X+Y)

R.H.S

(X’+Y’).(X+Y)

= X’.(X+Y)+Y’.(X+Y)

= X.X’+X’.Y+Y.X+Y’.Y

= X’.Y+Y’.X

= X’.Y+X.Y’

So L.H.S=R.H.S

OR

L.H.S.

X’.Y + X.Y’

= (X’.Y+X)(X’.Y+Y’)

= (X’+X).(Y+X).(X’+Y’).(Y+Y’)

= 1.(X+Y).(X’+Y’).1

(2)

[17]

= (X+Y).(X’+Y’)

= R.H.S.

(2 Marks for correct verification)

(b) State the two forms of Absorption Law

Ans:

X+XY=X

X(X+Y)=X

( ½ Mark for each form)

(1)

(c) Write the Boolean Expression for the result of the Logic Circuit as shown below:

(U’+V).(V’+W)

(1 Marks for the final expression)

(1)

(d) Derive a Canonical SOP expression for a Boolean function F, represented by thefollowing truth table:

P Q R F(P,Q,R

)

0 0 0 1

0 0 1 0

0 1 0 1

0 1 1 1

1 0 0 0

1 0 1 0

1 1 0 1

1 1 1 1

(1)

[18]

f(P,Q,R)=P’.Q’.R’+P’.Q.R’+P’.Q.R+P.Q.R’+P.Q.R

OR

f(P,Q,R) = ∑(0,2,3,6,7)

(1 Mark for the correct SOP form)

Note: Deduct 1⁄2 mark if wrong variable names are used

(e) Reduce the following Boolean Expression to its simplest form using K‐Map:

F(A,B,C,D) = Σ(3,4,5,6,7,13,15)

C’ D’ C’ D C D C D’

A’ B’

A’ B

A B

A B’

F (A, B, C, D) = A’ B + B D + A’ C D

( 1⁄2 Mark for drawing K-Map with correct variable names)

( 1⁄2 Mark for placing all 1s at correct positions in K-Map)

( 1⁄2 Mark for each grouping)

( 1⁄2 Mark for writing final expression in reduced/minimal form)

0

1

1 3

2

1 4

1 5

1 7

1 6

12

1 13

1 15

14

8

9

11

10

(3)

7 a) Perfect Education Services Ltd. is an educational organization. It is planning to setup its India

campus at Chennai with its head office at Delhi. The Chennai campus has 4 main buildings-

ADMIN, ENGINEERING, BUSINESS and MEDIA. You as a network expert have to

suggest the best network related solutions for their problems raided in (i) to (iv) keeping in

mind the parameters given below:

[19]

i) Suggest the most appropriate location of the server inside the CHENNAI campus, to get

the best connectivity for maximum no. of computers. Justify your answer. Ans:

Admin – as it has maximum number of computers

( ½ mark for the correct answer and ½ mark for correct reason)

ii) Suggest and draw the cable layout to efficiently connect various buildings within the

CHENNAI campus for connecting the computers.

Ans:

(1)

(1)

[20]

( 1 mark for the correct layout)

iii) Which hardware device will you suggest to be procured by the company to connect the

server to the internet?

Ans: Modem

( 1 mark for the correct answer)

iv) The organization is planning to link Chennai office with the sale counters situated in

various parts of the same city.Which type of network out of LAN, MAN or WAN will be

formed? Justify your answer.

Ans:

It will form a MAN as the nodes of the network are distributed over a city.

(½ Mark for suggesting MAN and ½ for appropriate reason)

(1)

(1)

v) Expand FTP and FSF.

Ans:

FTP – FILE TRANSFER PROTOCOL

FSF – FREE SOFTWARE FOUNDATION

(½ Mark each for correct expansion)

(1)

(b) Write two main characteristics of cloud computing?

Ans:

Ans:Cloud computing is computing in which large groups of remote servers are networked to allow

the centralized data storage, and online access to computer services or resources.

(½ Mark each for correct answer)

(1)

[21]

(c) Poonam is trying for on-line subscription to a magazine. For this she has filled in a form on the

magazine’s web site. When she clicks submit button she gets a message that she has left e-mail

field empty and she must fill it. For such checking which type of script is generally executed –

client-side script or server-side script?

Ans:

Client-side script (example VB scripting, JAVA scripting or PHP)

(1 Mark for correct answer)

(1)

(e) Give one difference between radiowave and microwave communication.

Ans:

Radiowave : Frequency is less than 3 GHz

Microwave: Frequency is more than 3 GHz

(1 Mark for correct difference)

(1)

(f) What is the role of TCP/IP in transmitting data from one computer to another?

Ans:

TCP breaks the message into small packets. IP part uses the numeric IP addresses to join these packets at the

receivers end.TCP/IP provides reliable delivery of messages between the two computers.

(1 Mark each for correct answer)

(2)

(g) Give one advantage and one disadvantage of Star topology.

Ans:

Advantage:

(i) Ease of service

(ii) Centralized control

Disadvanatge

(i) Long cable length

(ii) Difficult to expand

(iii) Central node dependency

( ½ mark each for correct advantage and disadvantage)(Only one advantage and one disadvantage to be

marked)

(1)