Series SHC: Computer Science
Series SHC: Computer Science
Series SHC: Computer Science
COMPUTER SCIENCE
Time allowed : 3 hours Maximum Marks: 70
Instructions:
(i) All questions are compulsory.
(ii) Programming Language : C++
1. (a) Differentiate between a Logical Error and Syntax Error. Also give suitable examples
of each in C++. 2
(b) Name the header file(s) that shall be needed for successful compilation of the
following C++ code : 1
void main( )
{
char Text[40];
strcpy(Text,”AISSCE”);
puts(Text);
}
(c) Rewrite the following program after removing the syntactical error(s), if any.
Underline each correction. 2
#include <iostream.h>
const int Size 5;
void main()
{
int Array[Size];
Array = {50,40,30,20,10};
for(Ctr=0; Ctr<Size; Ctr++)
cout>>Array[Ctr];
}
91 1 P.T.O.
P.T.O.
(d) Find the output of the following program : 2
#include<iostream.h>
void main()
{
int Numbers[] = {2,4,8,10};
int *ptr = Numbers;
for (int C = 0; C<3; C++)
{
cout<< *ptr << “@”;
ptr++;
}
cout<<endl;
for(C = 0; C<4; C++)
{
(*ptr)*=2;
--ptr;
}
for(C = 0; C<4; C++)
cout<< Numbers [C]<< “#”;
cout<<endl;
}
91 2
(f) In the following C++ program what is the expected value of Myscore from Options
(i) to (iv) given below. Justify your answer. 2
#include<stdlib.h>
#include<iostream.h>
void main( )
{
randomize();
int Score[] = {25,20,34,56, 72, 63}, Myscore;
Myscore = Score[2 + random(2)];
cout<<Myscore<<endl; }
(i) 25
(ii) 34
(iii) 20
(iv) None of the above
(i) Name the specific features of class shown by Function 1 and Function 2 in the
above example.
(ii) How would Function 1 and Function 2 get executed ?
91 3 P.T.O.
(c) Define a class Travel in C++ with the description given below : 4
Private Members :
T_Code of type string
No_of_Adults of type integer
No_of_Children of type integer
Distance of type integer
TotalFare of type float
Public Members :
• A constructor to assign initial values as follows :
T_Code with the word “NULL”
No_of_Adults as 0
No_of_Children as 0
Distance as 0
TotalFare as 0
• A function AssignFare( ) which calculates and assigns the value of the
data member TotalFare as follows :
For each Adult
Fare (Rs) For Distance (Km)
500 >=1000
300 <1000 & >=500
200 <500
For each Child the above Fare will be 50% of the Fare mentioned in the
above table.
For example :
If Distance is 750, No_of_Adults = 3 and No_of_Children = 2
Then TotalFare should be calculated as
No_of_Adults * 300 + No_of_Children * 150
i.e. 3 * 300 + 2 * 150 = 1200
• A function EnterTravel( ) to input the values of the data members T_Code,
No_of_Adults, No_of_Children and Distance; and invoke the AssignFare( )
function.
• A function ShowTravel( ) which displays the content of all the data
members for a Travel.
(d) Answer the questions (i) to (iv) based on the following code : 4
class Teacher
{
char TNo[5], TName[20], DeptflO];
int Workload;
protected:
float Salary;
void AssignSal(float);
91 4
public:
Teacher( ) ;
void TEntry( ) ;
void TDisplay( );
};
class Student
{
char Admno[10], SName[20], Stream[10];
protected:
int Attendance, TotMarks;
public:
Student( );
void SEntry( );
void SDisplay( );
};
class School : public Student, public Teacher
};
char SCode[10], SchName[20];
public:
School ( ) ;
void SchEntry( );
void SchDisplay( );
};
(i) Which type of Inheritance is depicted by the above example ?
(ii) Identify the member functiion(s) that cannot be called directly from the objects
of class School from the following :
TEntry( )
SDisplay( )
SchEntry( )
(iii) Write name of all the member(s) accessible from member functions of class
School.
(iv) If class School was derived privately from class Teacher and privately from
class Student, then, name the member function(s) that could be accessed
through Objects of class School.
3. (a) Write a function in C++ which accepts an integer array and its size.as arguments
and replaces elements having even values with its half and elements having odd
values with twice its value. 4
Example : if an array of five elements initially contains the elements as
3, 4, 5, 16, 9
then the function should rearrange the content of the array as
6, 2, 10, 8, 18
(b) An array Arr[15][20] is stored in the memory along the row with each element
occupying 4 bytes. Find out the Base Address and address of the element Arr[3][2],
if the element Arr[5][2] is stored at the address 1500. 4
91 5 P.T.O.
(c) Write a function in C++ to delete a node containing customer’s information, from a
dynamically allocated Queue of Customers implemented with the help of the
following structure : 4
struct Customer
{
int CNo;
char CName[20];
Customer *Link;
};
(d) Write a function in C++ which accepts a 2D array of integers and its size as
arguments and displays the elements of middle row and the elements of middle
column. 2
[Assuming the 2D Array to be a square matrix with odd dimension
i.e. 3×3, 5×5, 7×7 etc...]
Example, if the array content is
3 5 4
7 6 9
2 1 8
Output through the function should be :
Middle Row : 7 6 9
Middle Column : 5 6 1
(e) Evaluate the following postfix notation of expression : 2
15 3 2 + / 7 + 2 *
4. (a) Observe the program segment given below carefully, and answer the question that
follows : 1
class Labrecord
{
int Expno;
char Experiment[20];
char Checked;
int Marks;
public :
//function to enter Experiment details
void EnterExp( );
//function to display Experiment details
void ShowExp ( ) ;
//function to return Expno
char RChecked ( ) {return Checked;}
//function to assign Marks
void Assignmarks(int M)
{ Marks = M;}
91 6
};
void MpdifyMarks()
{ fstream File;
File.open(“Marks.Dat”,ios::binary|ios::in|ios::out);
Labrecord L;
int Rec = 0;
while (File.read((char*)&L, sizeof(L)))
{
if(L.RChecked( )== ‘N‘ )
L.Assignmarks(0)
else
L.Assignmarks(10)
_____________________ //statement 1
_____________________ //statement 2
Rec ++ ;
}
File.close ();
}
If the funption ModifyMarks() is supposed to modify Marks for the records in the file
MARKS.DAT based on their status of the member Checked (containing value either
'Y' or ‘N’). Write C++ statements for the statement 1 and statement 2, where,
statement 1 is required to position the file write pointer to an appropriate place in
the file and statement 2 is to perform the write operation with the modified record.
(b) Write a function in C++ to print the count of the word the as an independent word
in a text file STORY.TXT. 2
For example, if the content of the file STORY.TXT is
There was a monkey in the zoo. The
monkey was very naughty.
Then the output of the program should be 2.
(c) Given a binary file SPORTS.DAT, containing records of the following structure type :
struct Sports
{
char Event[20];
char Participant[10][30];
};
Write a function in C++ that would read contents from the file SPORTS.DAT and
creates a file named ATHLETIC.DAT copying only those records from SPORTS.DAT
where the event name is “Athletics”. 3
5. (a) What is the importance of a Primary Key in a table ? Explain with a suitable
example. 2
91 7 P.T.O.
(b) Consider the following tables Consignor and Consignee. Write SQL commands for
the statements (i) to (iv) and give outputs for SQL queries (v) to (viii). 6
TABLE : CONSIGNOR
TABLE : CONSIGNEE
91 8
6. (a) State De Morgan’s Theorems and verify the same using truth table. 2
(b) Write the equivalent Canonical Product of Sum Expression for the following Sum of
Product Expression
F(X, Y, Z) = Σ (0, 2, 4, 5) 2
(c) Write the equivalent Boolean expression for the following Logic Circuit. 2
(c) Which of the following units measures the speed with which data can be
transmitted from one node to another node of a network ? Also, give the expansion
of the suggested unit. 1
(i) KMph
(ii) Mbps
(iii) MGps
91 9 P.T.O.
(d) “Hindustan Connecting World Association” is planning to start their offices in four
major cities in India to provide regional IT infrastructure support in the field of
Education & Culture. The company has planned to set up their head office in New
Delhi in three locations and have named their New Delhi offices as “Sales Office”,
”Head Office” and “Tech Office”. The company’s regional offices are located at
”Coimbatore”, “Kolkata” and “Ahmedabad”.
A rough layout of the same is as follows :
91 10
In continuation of the above, the company experts have planned to install the following
number of computers in each of their offices :
(i) Suggest network type (out of LAN, MAN, WAN) for connecting each of the
following set of their offices :
• Head Office and Tech Office
• Head Office and Coimbatore Office
(ii) Which device will you suggest to be procured by the company for connecting all
the computers within each of, their offices out of the following devices ?
• Modem
• Telephone
• Switch/Hub
(iii) Which of the following communication media, will you suggest to be procured
by the company for connecting their local offices in New Delhi for very effective and
fast communication ?
• Ethernet Cable
• Optical Fiber
• Telephone Cable
(iv) Suggest a cable/wiring layout for connecting the company’s local offices located
in New Delhi. Also,, suggest an effective method/technology for connecting the
company’s regional offices at “Kolkata”, “Coimbatore” and “Ahmedabad”. 4
91 11 P.T.O.