0% found this document useful (0 votes)
69 views12 pages

ASSESSMENT - I: 2014-2015 Class: Xii Computer Science: General Instructions

This document contains instructions and questions for a Computer Science assessment for Class XII students. It states that the assessment is 3 hours long and worth 70 marks. It provides general instructions like checking that the correct paper is received, importance of clear English, and time allotted for reading the paper. The document then lists 8 questions with multiple sub-parts related to topics in Computer Science like C++ code examples, header files, functions, classes, objects, and more.

Uploaded by

Parth Nakhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views12 pages

ASSESSMENT - I: 2014-2015 Class: Xii Computer Science: General Instructions

This document contains instructions and questions for a Computer Science assessment for Class XII students. It states that the assessment is 3 hours long and worth 70 marks. It provides general instructions like checking that the correct paper is received, importance of clear English, and time allotted for reading the paper. The document then lists 8 questions with multiple sub-parts related to topics in Computer Science like C++ code examples, header files, functions, classes, objects, and more.

Uploaded by

Parth Nakhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 12

INDIAN SCHOOL AL GHUBRA, MUSCAT

ASSESSMENT - I : 2014-2015
Time allowed:3 Hours CLASS: XII COMPUTER SCIENCE M. Marks: 70

General Instructions:
 Check that you have the correct question paper.

 Check that this question paper contains 12 printed pages.

 Answer ALL the questions.

 The marks for individual questions are shown in round brackets: e.g. (2).

 You are reminded of the importance of clear English and careful presentation in your
answers.

 Programming Language: C++.

 You may use a soft pencil for any diagrams, or rough working.

 At the end of the examination, fasten all your work securely together.

 15 minutes time has been allotted to read this question paper. Students will read the
question paper only and will not write any answer on the answer-book during this
period.

 You must ensure that the answers to parts of questions are clearly labelled.

 There are VIII questions with sub divisions in this question paper.

I. a) Give the differences between actual parameters and formal parameters?. Also give a suitable C++ code to
illustrate both. (2)

b) Which C++ header file(s) are essentially required to be included to run/execute the following C++ source
code? ( Note: Do not include any header file(s) , which is/are not required). (1)

void main()
{
char TIPS[]=”Don’t look where you fall, look where you slip”;
for(int i=0; i<strlen(TIPS); i++)

(isdigit(TIPS[i]))? cout<<”#” : cout<<TIPS[i];

getch();

Page 1 of 12
c) Observe the following program and find out, which output(s) out of (i) to (iv) will be expected from the
program? Justify your answer. (2)

#include<iostream.h>
#include<stdlib.h>

void main( )
{
randomize( );
int Mynum, max=5;
Mynum = 20 + random(max);
for(int N=Mynum; N<=25; N++)
cout<<N<<”*”;
}

Options

i) 20*21*22*23*24*25

ii) 22*23*24*25*

iii) 23*24*

iv) 21*22*23*24*25*

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

include<iostream>
typedef shar[80] String;
void main()
{
String S = “Peace”;
int L = strlen(S);
cout<<S<<”has’<<L<<characters<<endl;
}

e) Find the output of the following program: (3)

#include<iostream.h>
#include<ctype.h>
void Encryption( char CH[], int M);
void main()
{
char Text[]="BEHAPPYALWAYS";
Encryption(Text, 1);
cout<<Text;
Page 2 of 12
}

void Encryption( char CH[], int M)


{
for(int I=0; CH[I]!='\0'; I++)
if(I%2==0)
CH[I]+=M;
else if(isupper(CH[I]))
CH[I]=tolower(CH[I]);
else
CH[I]-=M;
}

f) Find the output of the following program: (2)

#include<iostream.h>
#include<conio.h>

void output(int a, int b, int c)


{
cout<<"a="<<a;
cout<<"b="<<b;
cout<<"c="<<c;
cout<<endl;
}

void main()
{
int A[]={1001,2001,3001,4001};
output(++A[0], --A[0], A[0]++);
output(--A[0], ++A[0], --A[0]);
}

II. a) Enlist the differences between data encapsulation and data abstraction. (2)

b) Name the Object Oriented features implemented in the following C++ code: (2)

class WestWorldSchool
{
private:
char Stu_Name[20];
char Gender;
protected:
int Expected_Mark_Project;
int Expected_Mark_Practical;
Page 3 of 12
int Expected_Mark_Theory;
public:
int Expected_Mark_Total;
void INPUT(); // To input the data member details except Expected_Mark_Theory
void SHOW(); // To display data member details on screen
void CALCULATE(); // To calculate Expected_Mark_Total of all students
void CALCULATE(char Gen);// To calculate Expected_Mark_Total of Boys.
WestWorldSchool(); // To assign initial values for the data members.
};

III. a) Define the following terms: (2)


i) Function Overloading
ii) Constructor Overloading

b) Identify the FDs selected for FCs during compile time from the following C++ program: (2)

FD  Function Definition
FC  Function Call

#include<iostream.h>
#include<conio.h>

void callme(int a, float b) //FD 1


{
cout<<"void callme(int, float)\n";
}

void callme(char c, float b) //FD 2


{
cout<<"void callme(char,float)\n";
}

void callme(double d) //FD 3


{
cout<<"void callme(double)\n";
}

void callme(long l, float b) //FD 4


{
cout<<"void callme(long,float)\n";
}

void callme(float a) //FD 5


{
cout<<"void callme(float)\n";
}

void callme(long double a) //FD 6


{
cout<<"void callme(long double)\n";
Page 4 of 12
}

void main()
{
callme(4,66); // FC 1
callme('a',44); // FC 2
callme(77.334); // FC 3
callme(6.33); // FC 4
callme(65.33L); // FC 5
getch();
}

IV. a) Define a class RESTRA in C++ with following description: (4)


Private Members:
 FoodCode of type int
 Food of type string
 FType of string
 Sticker of type string
 A member function GetSticker() to assign the following values for Sticker as per the given FType:

FTpe Sticker
Vegetarian GREEN
Eggtarian YELLOW
Non-Vegetarian RED

Public Members:
 A function GetFood() to allow user to enter values for FoodCode, Food, FType and call function
GetSticker() to assign Sticker.
 A function ShowFood() to allow user to view the content of all the data members.

b) Find the output of the following program: (3)

#include<iostream.h>
#include<conio.h>

class METRO
{
int Mno;
int Tripno;
int Passengercount;
public:
METRO(int Tmno =1)
{
Mno=Tmno;
Tripno=0;
Passengercount=0;
}
void Trip( int PC=20)

Page 5 of 12
{
Tripno++;
Passengercount+=PC;
}
void Status()
{
cout<<Mno<<”:”<<Tripno<<”:”<<Passengercount<<endl;
}
};

void main()
{
METRO M(5), T;
M.Trip();
T.Trip(50);
M.Status();
M.Trip(30);
T.Status();
M.Status();
}
c) When can you make a member function as an inline member function? What is the advantage of an inline
function? (1)

d) Rewrite the following program after removing syntactical error(s) if any. Underline each correction (2)

#include <iostream.h>
#include <stdio.h>
class XLOG
{
int Parcel_Number;
char Customer[25]=”XLM”;
char Content[20];

public:

void Register_Parcel(int PN, char Name[])


{
Parcel_Number = PN;
Customer = Name;
gets(Content);
}

void Display()
{
cout<<Parcel_Number<<Customer<<Content<<”\n”;
}

};

void main()
{

Page 6 of 12
XLOG NEW;
NEW.Register_Parcel(00968, “Rooney”);
Display();
getch();
}

e) Differentiate between “Class” and “Object”. (2)

f) List any two characteristics a static data members with respect to Object Oriented Programming. (1)

V. a) Answer the questions (i) to (iv) after going through the following class: (4)

class Substitution
{
char Teacher_Absent[20];
int Lesson_No;
char Substitute[20];
char Date[10];

public:

Substitution() //Function 1
{
cin>>Teacher_Absent;
cin>>Lesson_No;
cin>>Substitute;
cin>>Date;
cout<<”Substitution Arranged”;
}

~Substitution() //Function 2
{
cout<<”Substitution Cancelled”;
}

Substitution(int LN, char Abse[], char subs[], char da[]) // Function 3


{
strcpy(Teacher_Absent, Abse);
strcpy(Substitute, subs);
strcpy(Date,da);
Lesson_No=LN;
}

Substitution( Substitution &S); // Function 4

};

i) In Object Oriented Programming, what are Function 1 and Function 4 combined together referred
as?
ii) In Object Oriented Programming which concept is illustrated by Function 2? When is this function
called / invoked?

Page 7 of 12
iii) In Object Oriented Programming, what is the name of Function 3? Write a line of code to call /
invoke
this function.
iv) Write a line of code to call Function 4.

b) What is the difference between implicit call and explicit call with respect to constructor functions? Give a
C++ example to illustrate both. (3)

c) What is the need for a copy constructor function in a class? Enlist the two situations where copy constructor
called / invoked (3)

VI. a) Answer the questions (i) to (iv) based on the following: (4)

class CUSTOMER
{
int Cust_no;
char Cust_Name[20];
protected:
void Register();
public:
CUSTOMER();
void Status();
};

class SALESMAN
{
int Salesman_no;
char Salesman_Name[20];
protected:
float Salary;
public:
SALESMAN();
void Enter();
void Show();
};

class SHOP : publuc CUSTOMER , public SALESMAN


{
char Voucher_No[10];
char Sales_Date[8];
public:
SHOP();
void Sales_Entry();
void Sales_Detail();
};

(i) Write the names of member functions which are accessible from objects belonging to class CUSTOMER.
(ii) Write the names of all the member functions which are accessible from objects belonging to class
SALESMAN.
(iii) Write the names of all the data members which are accessible from member functions of class SHOP.
(iv) How many bytes will be required by an object belonging to class SHOP and CUSTOMER?

Page 8 of 12
b) Define the following terms: (3)
i) Virtual Base class
ii) Base class
iii)Abstract Base class

c) What will be displayed on screen, when the object NN goes out with respect to the following code: (3)
class Nana
{
public:
Nana()
{
cout<<” Retirement is not a finishing line \n”;
}

~Nana()
{
cout<<” It is a Refreshing start \n”;
}
};

class Nani : public Nana


{
public:
Nani()
{
cout<<” I have never felt \n”;
}

~Nani()
{
cout<<” So Alive all my Life \n”;
}
};

class NanaNani: public Nani


{
public:
NanaNani()
{
cout<<”Live the Golden Years\n”;
}

~NanaNani()
{
cout<<”Smile for ever\n”;
}
};

void main()
{

Page 9 of 12
NanaNani NN;
}

VII. a) Write an user defined function that count the number of independent words ‘like’ from a text file
LINES.TXT. (3)

For example, if the file contains the following text

I like people like you who like others like me and make others like me to like others like you

The output is 7

b) A garage specializes in selling second hand cars. A binary file GARAGE.dat is used to store information
on the cars for sale. The file contains records/objects of the class GARAGE, which is defined below.

class GARAGE
{
char Make[20];
char Model[20};
char Color;
int Number_of_Doors;
char Registration_Number;
float price;
public:
void Display()
{
cout<<Make<<”#”<<Model<<”#”<<Color<<”#”<<Number_of_Doors<<”#”<<endl;
}

char* GetColor()
{
return color;
}
};

Write a function in C++, to search and display the details of cars, which have “green” color from the binary
file GARAGE.dat. (4)

c) Differentiate between the following file modes: (2)

i) ios::out and ios::app


ii) ios::nocreate and ios::noreplace

d) Observe the program segment given below carefully and answer the questions that follow: (1)

class Stock
{
int Ino;
int Qty;
char Item[20];
public:
Page 10 of 12
void Enter()
{
cin>>Ino;
gets(Item);
cin>>Qty;
}

void Issue(int Q)
{
Qty + = Q;
}

void purchase(int Q)
{
Qty - = Q;
}

int Getinfo()
{
return Ino;
}
};

void PurchaseItem(int Pino, int PQty)


{
fstream File;
File.open(“Stock.dat”, ios::binary | ios:in | ios:out);
Stock S;
int Success=0;
while( Success == 0 && File.read((char *)&S, sizeof(s)))
{
if(Pino==S.Getinfo())
{
S.purchase(PQty);
_______________________ // Statement 1
_______________________ // Statement 2
Success++;
}
}
if(Success == 1)
cout<<”Purchase updated”;
else
cout<<”Wrong Item No”;
File.close();
}

i) Write Statement 1 to position the file pointer to the appropriate place, so that the data updating is
done for the required item.
ii) Write Statement 2 to perform the write operation so that the updating is done in the binary file.

e) Write the differences between tellp() and tellg(). (2)

Page 11 of 12
VIII. a) Find the output of the following program: (4)

#include<iostream.h>
void main()
{
int *Queen, Moves[] = { 11, 22, 33, 44};
Queen = Moves;
Moves[2]+=22;
cout<<”Queen @”<<*Queen<<endl;
*Queen-=11;
Queen+=2;
cout<<”Now @”<<*Queen<<endl;
Queen++;
cout<<”Finally @”<<*Queen<<endl;
cout<<”New Origin @”<<Moves[0]<<endl;
}

b) What is self-referential structure? (1)

Page 12 of 12

You might also like