Follow on G+

NCERT Solutions for Class 12 Computer Science (C++) – Solved Paper, 2017 (Delhi Set)

NCERT Solutions for Class 12 Computer Science (C++) – Solved Paper, 2017 (Delhi Set)

The solution of all the chapters has been prepared very carefully by our computer expert teachers which will enhance the students' understanding of computers and also increase their interest.

NCERT Solutions for Class 12 Computer Science (C++) having 14th Chapter whose Chapter wise Solution given below.

Delhi Set    Code No. 90/1

SECTION – A

(Only for Candidates, who opted for C++)

Question 1:
(a) Write the type of C + + tokens (keywords and user defined identifiers) from the following : 2

(i) For
(ii) delete
(iii) default
(iv) Value

(b) Anil typed the following C+ + code and during compilation he found four errors as follows : 1

(i) Function strlen should have a prototype
(ii) Undefined symbol cout
(iii) Undefined symbol endl
(iv) Function getchar should have a prototype

On asking his teacher told him to include necessary header files in the code. Write the names of the header files, which Anil needs to include, for successful compilation and execution of the following code :

void main ()
{
char S [ ] = “Hello",
for (int i = 0; i < strlen (s); i++)
S[i] = S[i] + 1, 
cout<<B<<endl; 
getchar ();
}

(c) Rewrite the following C++ code after removing
any/all syntactical errors with each correction underlined.    2
Note : Assume all required header files are already being included in the program.

void main ()
{
cout «“Enter an integer”; 
cin » N; 
switch (N%2)
case 0 cout<<“Even”; Break; 
case 1 cout<<“Odd”; Break;
}

(d) Find and write the output of the following C+ + program code :    2
Note : Assume all required header files are already included in the program.

# define Big (A, B) (A > B) ? A + 1: B + 2
void main ()
{  char w [ ] = “Exam”; 
int L = strlen (w);
 for (int i = 0, i < L - 1, i ++) 
w [i] = Big (w[i], w [i + 1]); 
cout < < w < < endl;
}

(e) Find and write the output of the following C+ + program code :    3
Note : Assume all required header files are already being included in the program.

void main ()
{
int A [ ] = {10,12,15,17,20, 30}, 
for (int i = 0, i < 6, i+ +) 
{
if (A [i] % 2 = = 0)
A [i] / = 2;
else if (A [i] % 3 = = 0)
A [i] / = 3;
if (A [i] % 5 = = 0)
A [i] / = 5;
}
for (i = 0; i < 6; i ++)
cout<< A [i] <<“#”,
}

(f) Look at the following C++ code and find the possible output(s) from the options (i) to (iv) following it. Also, write the maximum values that can be assigned to each of the variables R and C.    2
Note:
• Assume all the required header files are already being included in the code.
• The function random (n) generates an integer between 0 and n -1.

void main ()
 {
 randomize ();
 int R = random (3), C = random (4);
 int MAT [3] [3] = { { 10, 20, 30}, (20, 30, 40}, (30, 40, 50}},
 for (int I = 0,1 < R, I + +)
 {
 for (int J = 0; J < C; J ++)
 cout << MAT [I] [J] <<“ cout<< endl,
 }
 }

 (i)

(ii)

10         20        30

20         30        40

30         40        50

10       20        30

20       30        40

(iii)

 (iv)

10       20

20       30

10       20

20       30

30       40

Solution:
(a)

(i) For – identifier
(ii) delete – keyword
(iii) default – keyword
(iv) Value – identifier

(b) string.h stdio.h
(c)

void main ()
{
cout<<“Enter an integer”;
cin >> N;
switch (N % 2)
{
Case 0 : cout<<“Even”; break;
Case 1 : Lcout<<“Odd”; break;
}
}

(d) Output:
zyom
(e) 1 # 6# 1# 17# 2# 3#
(f) R = 0,1,2 C = 0,1,2,3
Maximum value of R = 2, C = 3 option (ii) or (iii) is possible

Question 2:
(a) Differentiate between private and public members of a class in context of Object Oriented , Programming. Also give a suitable example illustrating accessibility/non-accessibility of each using a class and an object in C ++.    2
(b) Observe the following C++ code and answer the questions (i) and (ii).
Note : Assume all necessary files are included,

class EXAM 
{
 long code; 
char EName [20]; 
float Marks; public :
 EXAM ()    //Member Function 1
 {
 code = 100, strcpy (EName, “Noname”); Marks = 0;
 }
 EXAM (EXAM &E) //Member Function 2
 {
 code = E.code + 1; 
strcpy (EName, E.EName);
 Marks = E. Marks;
 }
 };
 void main ()
 {
 ___________    //Statement 1
  ___________   //Statement 2

(i) Which Object Oriented Programming feature is illustrated by the Member Function 1 and Member Function 2 together in the class EXAM ?    1
(ii) Write Statement 1 and Statement 2 to execute Member Function 1 and Member Function 2 respectively.    1

(c) Write the definition of a class RING in C+ + with following description :    4
Private Members

- RingNumber // data member of integer type
 - Radius   // data member of float type
 - Area    // data member of float type
 - CalcArea ( ) // Member function to calculate and assign 
// Area as 3.14 ‘Radius* Radius

Public Members

- GetArea ()    //A function to allow user
 to enter values of
 // RingNumber and Radius. Also, this
 // function should call CalcArea () to calculate // Area
 - ShowArea () // A function to display RingNumber, Radius // and Area

(d) Answer the questions (i) to (iv) based on the following:    4

class One
 {
 int Al, 
protected : 
float A2; 
public :
 One ();
 void Get 1 (); void show1 ();
 };
 class Two : private One
 {
 int B1; 
protected: 
float B2; 
public :
 Two (), 
void Get2 (); 
void Show ();
 };
 Class Three : public Two
 {
 int Cl; 
public :
 Three (); 
void Get 3 (); 
void Show ();
 };
 void main ()
 {
 Three T;    //Statement 1
 ______, //Statement 2

(i) Which type of inheritance out of the following is illustrated in the above example?
Single Level Inheritance, Multilevel Inheritance, Multiple Inheritance.
(ii) Write the names of all the member j. functions, which are directly accessible by the object T of class Three as declared in
main () function,
(iii) Write Statement 2 to call function Show () of class Two from the object T of class Three.
(iv) What will be the order of execution of the constructors, when the object T of class Three is declared inside main () ?
Solution:
(a) Private members: These members are hidden from the outside world. They can be accessed only by member
functions of the same class.
Public members:
These members are visible to the outside world. They can be accessed by objects.
(eg)

class student
{
private:
int rollno; 
char name [50]; 
public :
void get (); 
void show ();
};
student s.object; 
s.rollno —> × not accessible 
s.get () —> ✓ accessible

(b)
(i) Constructor overloading (Polymorphism)
(ii)

EXAM e1;           // statement 1
EXAM e2 (e1);     // statement 2

(c) 

{
int Ring Number; 
float Radius; 
float Area; 
void Calc Area ()
{
Area = 3.14 * Radius * Radius;
}
 public :
void GetArea ()
{
cout <<“Enter Ring Number and Radius"; 
cin >>Ring Number >> Radius;
CalcArea ();
}
void ShowArea ()
{
cout<<“RingNumber : “<<Ring Number<< endl; 
cout<<“Radius : “ << Radius << endl; 
cout<<“Area : “ << Area << endl;
}
};

(d)

(i) Multilevel inheritance.
(ii) Get 3 (), Show (), Get 2 (), Show ()
(iii) T. super (Show ())
(iv) One (), Two (), Three ().

Question 3:
(a) Write the definition of a function Reverse (int Arr [ ], int N) in C++, which should reverse the entire content of the array Arr having N elements, without using any other array. 3

Example: if the array Arr contains

13

10

15

20

5

Then the array should become

5

20

15

10

13


Note:• The function should only rearrange the content of the array.

• The function should not copy the reversed content in another array.
• The function should not display the content of the array.
(b) Write definition for a function ADDMIDROW (int MAT[ ] [10], int R, int C) in C++, which finds sum of the middle row elements of the matrix MAT (Assuming C represents number of Columns and R represents number of rows, which is an odd integer).    2For example, if the content of array MAT having R as 3 and C as 5 is as follows :

1

2

3

4

5

2

1

3

4

5

3

4

1

2

5

The function should calculate the sum and display the following:
Sum of Middle Row : 15

(c) T[25][30] is a two dimensional array, which is stored in the memory along the row with each of its element occupying 2 bytes, find the address of the element T[10] [15], if the elements T[5] [10] is stored at the memory location 25000.    3
(d) Write the definition of a member function ADDMEM () for a class QUEUE in C+ +, to add a MEMBER in a dynamically allocated Queue of Members considering the following code is already written as a part of the program. 4

struct Member
 {
 int MNO;
 char MNAME (20);
 Member *Next;
 };
Class QUEUE
{
Member “Rear, “Front; 
public :
QUEUE () {Rear = NULL, Front = NULL,) 
voidADDMEM (); 
void REMOVEMEM ();
~ QUEUE ();
};

(e) Convert the following Infix expression to its equivalent Postfix expression, showing the stack contents for each step of conversion. 2 P + (Q-R) * S/T
Solution:
(a)

Void Reverse (int Arr [ ], int N)
{
int temp;
for (int i = 0, j = N-1; i < j; i++, j--)
{
temp = Arr [i]; 
Arr [i] = Arr [j]; 
Arr [j] = temp; }

(b)

Void . ADDMIDROW (int MAT [ ] [10], int R, int C)
{
int mid = R/2, sum = 0; 
for (int j = 0; j < C; j + +)
sum = sum + MAT [mid] [j]; 
cout<<“Sum of Middle Row << sum;

(c)

T[5] [10] = 25000 nr = 25 nc = 30 w = 2 bytes
T[i] [j] = BA + size * (i * nr + j) 
i-sr j-sc
T[10] [15] = 25000 + 2* ((10 - 5) * 25 + (15 - 10))
= 25 000 + 2* (125 + 5)
= 25000 + 260 
= 25260

(d)

Void QUEUE :: ADDMEM ()
{
Member * newnode = new Member; 
cout <<“Enter member no”; 
cin >> newnode —> MNO;
cout <<“Enter member name”;
gets (newnode —> MNAME);
 newnode -> Next = NULL;
if (Rear = = NULL)
{
Rear = newnode;
Front = newnode;
else
Rear —> Next = newnode;
Rear = newnode
}
}

(e) (P + (Q – R) * S / T)

Symbol

Stock

Expression

(

(

P

(

P

+

( +

P

(

( + (

P

Q

( + (

PQ

( + (-

PQ

R

( + (-

PQR

)

( +

PQR-

*

( + *

PQR-

S

( + *

PQR-S

/

( + /

PQR-S*

T

( + /

PQR-S*T

)

PQR-S*T/+

Answer:
PQR – S * T / +

 

Question 4:
(a) Aditi has used a text editing software to type some text. After saving the article as WORDS. TXT, she realised that she has wrongly typed alphabet J in place of alphabet I everywhere in the article.    3
Write a function definition for JTOI () in C+ + that would display the corrected version of entire content of the file WORDS.TXT with all the alphabets “J” to be displayed as an alphabet “I” on screen.
Note : Assuming that WORD.TXT does not contain any J alphabet otherwise.
Example:
If Aditi has stored the following content in the file WORDS.TXT:

WELL, THJS JS A WORD BY JTSELF. YOU COULD STRETCH THJS TO BE A SENTENCE

The function JTOI ( ) should display the following content:

WELL, THIS IS A WORD BY ITSELF. YOU COULD STRETCH THIS TO BE A SENTENCE

(b) Write a definition for function COUNTDEPT () in C++ to read each object of a binary file TEACHERS.DAT, find and display the total number of teachers in the department MATHS. Assume that the file TEACHERS.DAT is created with the help of objects of class TEACHERS, which is defined below :    2

class TEACHERS
{
intTID; char DEPT [20]; 
public :
void GET ()
{
cin >> TID, get, (DEPT);
}
void SHOW ()
{
cout<< TID << "i" «DEPT«endl;
}
char *RDEPT () {return DEPT;}
}

(c) Find the output of the following C++ code considering that the binary file BOOK.DAT exists on the hard disk with a data of 200 books.    1

class BOOK
{
int SID, char BName [20], 
public :
void Enter () void Display ();
};
void main ()
{
fstream InFile;
InFile.open ("BOOK.DAT", ios :: binary | ios : : in);
BOOK B;
InFile.seekg (5* sizeof (B)};
InFile, read (char *) &B, sizeof (B) 
cout«"Book Number«InFile.tellg ( ) / size of (B) + 1;
InFile.seekg (0, ios : : and); 
cout<<"of << IpFile.tellg () / size of (B) «endl;
InFile.close ();
}

Solution:

(a)

Void JTOI ()
{
fstream f ("WORDS.TXT"); 
char ch;
while (! f.eof ())
{
f > > ch; 
if (ch = = 'J')
cout < < 'I';
else
cout <<ch;
}
f.close ();
}

(b)

void COUNTDEPT ()
{
TEACHERS t; 
fstream f;
f.open ("TEACHERS.DAT”, ios :: binary: ios :: in); 
while (f.read ((char *) & t, size of (t))
{
if (strcmp (t.RDEPT (), "MATHS") = =0) 
count + +;
}
cout < <"No. of teachers of math department"
< < count; 
f.close ();
}

(c) Output:
Book Number : 7 of 200

SECTION – C

(For All the Candidates)

Question 5:
(a) Observe the following table CANDIDATE carefully and write the name of the RDBMS operation out of
(i) SELECTION (ii) PROJECTION (iii) UNION (iv) CARTESIAN PRODUCT, which has been used to produce the output as shown in RESULT. Also, find the Degree and Cardinality of the RESULT.    2

TABLE: CANDIDATE

NO

NAME

STREAM

Cl

AJAY

LAW

C2

ADITI

MEDICAL

C3

ROHAN

EDUCATION

C4

RISHAV

ENGINEERING

RESULT

NO

NAME

C3

ROHAN

(b) Write SQL queries for (i) to (iv) and find outputs for SQL queries (v) to (viii), which are based on the tables:    6

(ii) To display the BNO and BNAME of all Fiction Type books from the table Book.

(iii) To display the TYPE and number of books in each TYPE from the table BOOK.
(iv) To display all MNAME and ISSUEDATE of those members from table MEMBER who have books issued (i.e., ISSUEDATE) in the year 2017.
(v) SELECT MAX (ISSUEDATE) FROM MEMBER;
(vi) SELECT DISTINCT TYPE FROM BOOK;
(vii) SELECT A.CODE, BNAME, MNO, MNAME FROM BOOK A, MEMBER B WHERE A.CODE=B.CODE;
(viii) SELECT BNAME FROM BOOK
WHERE TYPE NOT IN (“FICTION”, “COMIC”);
Solution:
(a)

(ii) PROJECTION
Degree: 2
Cardinality: 1

(b)    

(i) Select * from MEMBER order by ISSUEDATE desc.
(ii) Select BNO, BNAME from BOOK where TYPE = “Fiction”;
(iii) Select distinct TYPE, count (TYPE) from Book group by TYPE.
(iv) Select MNAME, ISSUEDATE from MEMBER where ISSUEDATE like ‘2017 %’.
(v)

MAX (ISSUE DATE)
2017-02-23

(vi)

DISTINCT (TYPE)
Fiction
Literature
Comic

(vii)

CODE     BNAME         MNO     MNAME
L102   German easy     M101    RAGHAV SINHA
F102   Untold Story    M103    SARTHAK JOHN
C101   Tarzan in the   M102    ANISHA KHAN             
       lost World

(viii)

BNAME
German easy.

Question 6:
(a) State Distributive Laws of Boolean Algebra and verify them using truth table.    2
(b) Draw the Logic Circuit of the following Boolean
Expression using only NAND Gates :    2

X.Y+Y.Z

(c) Derive a Canonical SOP expression for a Boolean function F, represented by the following truth table:    1

 U

V

 W

F (U, V,W)

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

0

(d) Reduce the following Boolean Expression to its simplest from using K-Map :  3
F (X, Y, Z, W) = X (0,1, 2, 3, 4, 5,10,11,14)
Solution:
(a) Distributive laws.
A + B. C = (A + B) . (A + C)
A . (B + C) = (A. B) + (A.C)

(II) Law

A

B

C

B.C

A+B.C

A+B

A+C

(A+B).(A+C)

0

0

0

0

0

0

0

0

0

0

1

0

0

0

1

0

0

1

0

0

0

1

0

0

0

1

1

1

1

1

1

1

1

0

0

0

1

1

1

1

1

0

1

0

1

1

1

1

1

1

0

0

1

1

1

1

1

1

1

1

1

1

1

1

1) = (2) Hence proved.

 

A

B

C

B+C

A.(B+C)

A.B

AC

AB +AC

0

0

0

0

0

0

0

0

0

0

1

1

0

0

0

0

0

1

0

1

0

0

0

0

0

1

1

1

0

0

0

0

1

0

0

0

0

0

0

0

1

0

1

1

1

0

1

1

1

1

0

1

1

1

0

1

1

1

1

1

1

1

1

1

(3) = (4) Hence proved.

 

(b) X.Y+Y. Z
E:\image\NCERT Solutions for Class 12 Computer Science (C++) - Solved Paper, 2017 (Delhi & Outside Delhi Set)-1.png
(c) U’V’W + U’VW’+ U’VW + UVW’
(d) F (X, Y, Z, W) = I (0,1, 2, 3, 4, 5,10,11,14)
NCERT Solutions for Class 12 Computer Science (C++) - Solved Paper, 2017 (Delhi & Outside Delhi Set)-2
F = X’Z’ + Y’Z + XZW’

 

Question 7:
(a) Differentiate between Radio Link and Microwave in context of wireless communication technologies.    2
(b) Amit used a pen drive to copy files from his friend’s laptop to his office computer. Soon his office computer started abnormal functioning. Sometimes it would restart by itself and sometimes it would stop functioning totally. Which of the following options out of (i) to (iv), would have caused the malfunctioning of the computer ? Justify the reason for your chosen option: 2

(i) Computer Worm
(ii) Computer Virus
(iii) Computer Bacteria
(iv) Trojan Horse

(c) Jai is an IT expert and a freelancer. He recently used his skills to access the Administrator password for the network server of Megatech Corpn Ltd. and provided confidential data of the organization to its Director, informing him about the vulnerability of their network security. Out of the following options (i) to (iv), which one most appropriately defines Jai ?     2
Justify the reason for your chosen option:

(i) Hacker
(ii) Cracker
(iii) Operator
(iv) Network Admin

(d) Hi Speed Technologies Ltd. is a Delhi based organization which is expanding its office setup to Chandigarh. At Chandigarh office campus, they are planning to have 3 different blocks for HR, Accounts and Logistics related work. Each block has number of computers, which are required to be connected in a network for communication, data and resource sharing.


NCERT Solutions for Class 12 Computer Science

Post a Comment

0 Comments