· web viewwrite a get1from2( ) function in c++ to transfer the content from two arrays first[]...

42
MODEL QUESTION PAPER CLASS - XII Computer Science Max. Marks: 70 Duration: 3 Hours General Instructions – (i) All questions are compulsory. (ii) Programming Language : C++. Q1 . (a ) Write the two forms of type conversion facilitated by C++. Also give suitable example of each form of type conversion. [2] (b ) Name the header file required for successful compilation of the given snippet: #include<iostream.h> void main( ) { char str[20]; cout<<”\n Enter a string : ”;cin.getline(str,20); if( isupper(str[0]) ) cout<<”\nThe string is : “<<str; else exit(0); } [1] (c ) Underlining the syntactical errors (if any) with proper explaination. #include<iostream.h> void main() { int n = 44; int *ptr = &n; ++(*ptr); int *constcptr = &n; ++(*cptr); ++cptr; constintkn=88; constint *ptrc = &kn; ++(*ptrc); ++ptrc; constint *constcptrc =&kn; ++(*cptrc); ++cptrc; } [2] (d ) Find the output of the following program: #include<iostream.h> struct Solid { int length, breadth, height; }; void Dimension(Solid S) { cout<<S.length<<" "<<S.breadth<<" "<<S.height<<endl; } [3] Page 1 / 42

Upload: others

Post on 08-Jan-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

MODEL QUESTION PAPERCLASS - XII

Computer ScienceMax. Marks: 70 Duration: 3 Hours General Instructions – (i) All questions are compulsory.

(ii) Programming Language : C++.Q1. (a) Write the two forms of type conversion facilitated by C++. Also give

suitable example of each form of type conversion.[2]

(b) Name the header file required for successful compilation of the given snippet:

#include<iostream.h>void main( )

{ char str[20];cout<<”\n Enter a string : ”;cin.getline(str,20);if( isupper(str[0]) )

cout<<”\nThe string is : “<<str;else

exit(0);}

[1]

(c) Underlining the syntactical errors (if any) with proper explaination.#include<iostream.h>

void main(){ int n = 44;

int *ptr = &n;++(*ptr);int *constcptr = &n;++(*cptr);++cptr;constintkn=88;constint *ptrc = &kn;++(*ptrc);++ptrc;constint *constcptrc =&kn;++(*cptrc);++cptrc;

}

[2]

(d) Find the output of the following program:#include<iostream.h>struct Solid{ int length, breadth, height;};void Dimension(Solid S){ cout<<S.length<<" "<<S.breadth<<" "<<S.height<<endl;}void main(){

Solid S1={10,20,30},S2,S3;++S1.height;Dimension(S1);S3=S1;++S3.length;S3.breadth++;Dimension(S3);S2=S3;S2.height =+ 5;

[3]

Page 1 / 33

Page 2:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

S2.length = S2.length – 5;S2.breadth += 5;Dimension(S2);

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

#include<iostream.h>static int sum2=0;void sumfn(int last){

auto int sum1=0;for(inti=last;i>0;i--) sum1+=i;sum2 +=sum1;cout<<sum1<<" & "<<sum2<<endl;

}void main(){

sum2=10;for(inti=5; i<7 ; i++) sumfn(i);

}

[2]

(f) In the following program, what will be the expected output(s) from the given options?

#include <iostream.h>#include <stdlib.h>void main(){

int N;randomize();for (int I=1;I<=4;I++){

if(I%2==0)N=1+random(I);

elseN=5+random(I);

cout<<N;}

}(i) 5354 (ii) 5254(iii) 5173 (iv) 6264

[2]

Q2. (a) What do you understand by functional overloading? Give an example illustrating functional overloading using C++ coding.

[2]

(b) Answer the questions (i) and (ii) after going through the following program:class mytime{

int hour, minute, second;public:

mytime() //Function 1 void Details() //Function 2

{cout<<”The time is

“<<hour<<”:“<<minute<<”:”<<second<<endl;}

mytime(int x, int y, int z) //Function 3mytime(mytime&mt) //Function 4

};i) Write the complete function definition for Function 4.ii) Write statements that would call the Member Functions 1 and 3.

[2]

Page 2 / 33

Page 3:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

(c) Define a class IncomeTax in C++ with the following descriptions.Private members:

EmpName of type character arrayEmpcode of type long

Grosssalaryof type longNettax of type longCalculate( ) This member function should calculate the

value of Nettax according to the following conditions.

Grosssalary Tax to be paidUp to 1 Lakh No Tax>1 Lakh and <=3 Lakhs 10% of (Grosssalary – 1 Lakh)> 3 Lakhs and <=5 Lakhs 20,000 + 20% of (Grosssalary – 3

Lakhs)Above 5 Lakhs 60,000 + 30% of (Grosssalary – 5

Lakhs)

Public members: * A constructor to assign initial values of EmpName as “Ajay”,

Empcode as 53043, Grosssalary as 250000, Nettax as 15000.

* A function Accept() which allows user to enter EmpName, Empcode, Grosssalary and should call function Calculate().

* A function Display() to display the values of all the data members on the screen.

[4]

(d) Answer the questions (i) to (iv) based on the following:class HQ{      long HQmaxvalue; protected :

long HQfundvalue; public:intno_of_HQmeritcert;

HQ( );   void HQREAD( );    void HQWRITE( );

};

class RO: protected HQ{      intROcode;

long ROmaxvalue;protected:long ROfundvalue;public:intno_of_ROmeritcert; RO( );

void HQUPDATE( );   void ROREAD( );   void ROWRITE( );};

class KV: private RO{       intKVcode, no_of_achivements;

char KVname[30];      public:

[4]

Page 3 / 33

Page 4:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

long cashprize;KV( );void ROUPDATE( );void KVREAD( );

   void KVWRITE( );};

i) Mention the member names that are accessible by an object of RO class.

ii) Name the members which can be accessed by the objects of KV class.

iii) Name the date members that can be accessed by the ROUPDATE() of KV class.

iv) How many bytes will be occupied by an object of class KV?

Q3. (a) Assume that two arrays A and B contain objects of structure Teacher in the ascending order of salary. Write a function MERGE in C++ to merge the contents of arrays A & B into third array C. The resultant array should contain the objects of both arrays A & B. Array C should be sorted in ascending order of salary of the corresponding objects.The arrays A, B, C, No. of objects of A and B should be passed as the arguments to the function. Definition of structure Teacher is as under:

struct Teacher{

int ID;char Name[30];float Salary;

};

[3]

(b) An array P[20][30] is stored in the memory along the column with Base Address 3392. Find out the memory location for the element P[2][20], if an element P[5][15] is stored at the memory location 4612.

[3]

(c) Consider the following program for linked STACK:struct NODE{ int x;float y;NODE *next; };class STACK{ NODE *Rear,*Front;;public :

STACK( ){ Rear=NULL;Front=NULL;

}void PUSH( );void POP( );void Show( );~STACK(); };

Define PUSH( ) & POP( ) functions outside the class.

[4]

(d) Write a function in C++ to find sum of the elements of each row from AR[10][10] of integer type. The integer array and its size must be passed as arguments to the function.

[2]

(e) Evaluate the following postfix notation of expression:12, 7, 3, – , / , 2, 1, 5, + , , +

[2]

Page 4 / 33

Page 5:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

Q4. (a) Observe the program segment given below carefully, and answer the question that follows :class vidyalaya{ char name[25];intnumstu;public:void inschool( );void outschool( );intretnumstu( ){ return numstu; }};void modify(vidyalaya A){ fstream INOUT;

INOUT.open(“school.dat”,ios::binary|ios::in|ios::out|ios::ate);vidyalaya B;intrecread=0, found=0;while(!found &&INOUT.read((char*)&B,sizeof(B)){ recread++;if(A.retnumstu( )= = B.retnumstu( )){__________________//missing statement 1

__________________//missing statement 2Found=1;

}else

INOUT.write((char*)&B,sizeof(B));}if(!found)

cout<<”\nRecord for modification does not exist”;INOUT.close( );

}If the function modify( ) is supposed to modify a record in file school.dat with the values of vidyalaya A passed to its argument, write the appropriate statement for missing statements 1 & 2 so that the function would write the modified record at its proper place.

[1]

(b) Write a function in C++ to count the number of upper case alphabets present in a text file “NOTES.TXT”.

[2]

(c) Given the binary file BOOK.DAT, containing the records of the following structure:

class book{

intbook_no;char book_name[20];int stock;

public:intbookreturn(){

return book_no;}void DeleteStock(int);

};Write the complete definition of the function DelStock(), which delete the records that match with the book_no passed as the argument to

[3]

Page 5 / 33

Page 6:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

the function.Q5. (a) Explain any two levels of data abstraction in a database system. [2]

(b) Consider the tables ITEMS & COMPANY. Write SQL commands for the statements (i) to (iv) and give the outputs for SQL queries (v) to (viii).

Table : ITEMSID PNAME PRICE MDATE QTYT001 Soap 12.00 11/03/2007 200T002 Paste 39.50 23/12/2006 55T003 Deodorant 125.00 12/06/2007 46T004 Hair Oil 28.75 25/09/2007 325T005 Cold Cream 66.00 09/10/2007 144T006 Tooth Brush 25.00 17/02/2006 455

Table : COMPANYID COMP CityT001 HLL MumbaiT008 Colgate DelhiT003 HLL MumbaiT004 Paras HaryanaT009 Ponds NoidaT006 Wipro Ahmedaba

d

i). To display product name, company name & price for those items which IDs are equal to the IDs of company.

ii). To display PNAME, PRICE * QTY only for the city Mumbai.

iii). To display the items details from ITEMS table where the items are produced by Wipro Company.

iv). To increase the quantity by 20 for soap and paste.

v). SELECT COUNT(*) FROM ITEMS WHERE ITEMS.ID=COMPANY.ID;vi). SELECT PNAME FROM ITEMS WHERE PRICE=SELECT MIN(PRICE)

FROM ITEMS;vii). SELECT COUNT(*) FROM COMPANY WHERE COMP LIKE “P_ _ _ _”;viii). SELECT PNAME FROM ITEMS WHERE QTY<100;

[6]

Q6. (a) What are DeMorgan’s Theorems? Using truth table, prove any one of the DeMorgan’s Theorem.

[2]

(b) Draw the logic circuit for the Boolean expression using NAND gates only.X Y + X Y Z + X Y Z

[2]

(c) Convert the following Boolean expression into its equivalent Canonical Product of Sum form (POS):X Y Z + X Y Z + X Y Z + X Y Z

[1]

(d) Reduce the following Boolean Expression using K-Map:F( A, B, C, D ) = (2, 3, 5, 6, 7, 9, 11, 13, 14, 15)

[3]

Q7. (a) Mention any two advantages of networking. [1](b) Mention any two types of switching techniques. [1](c) How is a cracker different from a hacker? [1](d) Define the terms : Trojan Horses, Worm. [1](e) Write any two uses of Server Side Scripting. [1](f) Expand : (i) FLOSS (ii) FSF [1](g) “KVS E-Learning System” is planning to spread their facilities in different

KVs to provide regional IT infrastructure support in the field of Education. The head office has planned to setup in New Delhi. To promote E-Learning System, the following KVs alongwith Regional Office are planned to

[4]

Page 6 / 33

Page 7:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

connect their computer systems to this network. A rough layout of the same is as follows :

Approximate distances between these offices/KVs as per network survey team is as follows:

Place From Place To DistanceHead Office Regional Office 800 KmRegional Office KV 1 500 MeterRegional Office KV 2 1 KmRegional Office KV 3 3 KmRegional Office KV 4 2.5 KmKV 1 KV 2 500 MeterKV 1 KV 3 3.5 KmKV 1 KV 4 3 KmKV 2 KV 3 4 KmKV 2 KV 4 3.5 KmKV 3 KV 4 3 Km

In continuation of the above, the system experts have planned to use the following number of computers in each of their office/KVs :

Regional Office 15KV 1 60KV 2 20KV 3 45KV 4 30

(i) Suggest network type (out of LAN, MAN, WAN) for connecting each of the following set of their offices/KVs :

• KV 1 and KV 3• Regional Office and Head Office New Delhi

(ii) Which device you will suggest to be used by the system for connecting all the computers with in each of their offices/KVs out of the following devices?

Page 7 / 33

HEADOFFICE

NEW DELHI Region

al Office

Page 8:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

• Switch/Hub• Modem

(iii) Suggest the most suitable place (i.e. Office/KV) to house the server. Justify your answer.

(iv) The system experts are planning to link KV 5 situated in a hilly region where cable connection is not feasible, suggest an economic way to connect it with reasonably high speed?

-----XXX-----

KENDRIYA VIDYALAYA SANGATHANPRE-BOARD EXAMINATION

SUBJECT – COMPUTER SCIENCE (083)CLASS – XII

Time: 3 hrs. MM:70Instructions:

i) All questions are compulsory.ii) Programming Language : C++

Q.1 (a) What is the difference between implicit & explicit type casting? Give suitable examples to support your answer.

2

(b) Name the header file(s) that shall be needed for successful compilation of the following C++ code : void main( ){clrscr();char name[20];gets(name);if(strcmp(name,”KV”)==0)cout<<”String matched!!!”;

1

Page 8 / 33

Page 9:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

elsecout<<”Not matching!!!”;}

(c) Rewrite the following program after removing the syntactical error(s), if any. Underline each correction. #include <iostream.h>class InService{

intgroup_no;PUBLIC:void get_info(){cin>>group_no;}void disp_info{cout<<group_no;}}void main(){

InServiceI;I.get_info();disp_info();

}

2

(d) Find the output of the following program assuming all necessary header files are included:

void Encoding(char E[]){

for (inti=strlen(E);i>=0;i-=2)if (E[i]=='A' || E[i]=='E') E[i]='^';else if (isupper(E[i])) E[i]=tolower(E[i]);else E[i]='%';

}void main(){

char line[]="KeNdriYAVidyaLAya";//The two words in the string //line are separated by single spaceEncoding(line);cout<<line<<endl;

}

3

(e) Find the output of the following program-

#include<iostream.h>class student { public: student() { cout<<”\n Computer Science“; } ~student() { cout<<” subject”; } }st; void main() { cout<<“is my favourite”;}

2

Page 9 / 33

Page 10:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

(f) Study the following program and select the possible output from it. Also find the maximum & minimum value of count

#include<iostream.h>#include<stdlib.h>constintVAL=3;void main( ){ randomize( );intcount; count=70+random(VAL);for(intx=count;x>=70;x--)cout<<x<<”*”;}

(i) 70*71*(ii)71*70*

(iii)73*72*71*70*(iv)70*71*72*

2

Q.2 (a) Why an object in a copy constructor is passed by reference? How is it invoked?

2

(b) Answer the questions (i) and (ii) after going through the following class:class Commerce{char chapter[20];int Weightage;public:Commerce ( ) //Function 1{strcpy (chapter, “Java” );Weightage = 30;cout<<“chapter started”;} Commerce( Commerce &C); //Function 2~Commerce( ) //Function 3{cout’<<”chapter completed”;}(i) Name the specific features of class shown by Function 1 , Function 2 and Function 3 in the above example.(ii) Write complete definition for Function 2.

2

(c) Define a class TV_Channels in C++ with following description: Private Members:Channel number IntegerName of channel String of 25 charactersChannel type StringRecharge Cost Float (per month)Duration integer (in months)Total cost FloatPublic Members

A function INPUT( ) to allow the user to enter the values of Channel no,Name of channel,Channeltype,recharge cost per month, duration and call the function calculate() to find total cost.

A function Calculate( ) to find the total cost as per the following formula - recharge cost * duration.

A function OUTPUT( ) to allow user to view the content of all the data

4

Page 10 / 33

Page 11:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

members.

(d) Consider the following declarations and answer the questions given below: class School{ protected:

intschool_code; char school_name[50];

public:void Get_data();void Show_data();School( );~School( );

};class Primary: public School{protected:

intstrength;public:

void Get_primarydata(int);void Show_primarydata(int);Primary( );~Primary( );

};class Secondary: public School{int sections;public:

void Show_Secondarydata(void);Secondary( );

~Secondary( ); };

i) How many bytes will be required by an object belonging to class Secondary?

ii) Which type of inheritance is depicted in the above example?iii) List the data members that can be accessed by the member function

Show_primarydata( )iii) What is the order of constructor execution at the time of creating an object

of class Secondary?

4

Q.3 (a) Write a function REARRANGE( ) which takes an integer array and its size as arguments and modify the array elements in such a way that if the sum of an element and its adjacent element exceeds 20, that element should be replaced by 0. The last value remains unchanged.For example: If the content of the array is 2, 5, 16, 2, 12, 9 The content of array after execution should be 2, 0, 16, 2, 0, 9

4

(b) An array VAL[40][30] is stored in the memory along the row with each of the element occupying 2 bytes, find out the memory location for the element VAL[20][10], if an element VAL[15][5] is stored at the memory location 5500.

4

(c) Write a function in C++ to perform delete operation in circular Queue containing TOUR’s information as –

struct TOUR{intT_id; char T_name[20];

4

Page 11 / 33

Page 12:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

};

(d) Write a function which accepts an integer array and its size as arguments and assigns the value of lower elements, of the right diagonal of the 2 – D array as 0.For example:

1 2 3 1 2 34 5 6 4 5 07 8 9 7 0 0

2

(e) Evaluate the following postfix notation of expression:True, False, NOT, AND, False, True, OR, AND

2

Q.4 (a) Observe the program segment given below carefully, and answer the question that follows: class Candidate{

long CId; //Candidate’s Id char CName [20] ; //Candidate’s Name float Score; //Candidate’s Score

public: void Enroll ( ); void Disp ( ) ; void MarksScore ( ); / /Function to change Score longR_CId () {return CId;)

} ; void ScoreUpdate (long Id) {

fstream File; File.open (“Candi.DAT”,ios::binary|ios::in|ios::out); CandidateC; int Record = 0, Found = 0 ; while (!Found &&File.read((char*) &C, sizeof(C))) {

if(Id ==C.R_CId ( )) {

cout<<”Enter new Score” ; C.MarksScore ( ); ______________ / / Statement 1 ______________ / /Statement 2 Found = 1;

}Record ++;

}if (Found ==1) cout<<”Record Updated”; File.close ( ) ;

}Write the Statement1 to position the File Pointer at the beginning of the Record forwhich the Candidate’s ld matches with the argument passed, and Statement2 to write the updated Record at that position.

1

(b) Write a function that calculate the average word size in a text file “CONSOLIDATE.TXT” where each word is separated by a single space.

2

(c) Write a function in C++ to search for anOrder No from a binary file “Order.DAT”, assuming the binary file is containing the objects of the following class. class ORDER{

3

Page 12 / 33

Page 13:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

intOrder_no;char Member_type[20];

public:intRet_Ord_no(){return Order_no;}void get_val(){cin>>Order_no;gets(Member_type);}void disp_val(){cout<<Order_no<<Member_type<<endl;}

};

Q.5 (a) What are Views? What happens if we try to drop a table in which a view exists? 2

(b) Write SQL commands for (i) to (iv) and the outputs for (v) on the basis of tables MOVIES

Table: MOVIESNo Title Type Rating Star Qty Price1 Australia Comedy G Nicole Kidman 4 35.952 The Reader Comedy R Jason 2 69.953 The Dark Knight Action PG Heath Ledger 7 49.95

4Slum Dog Millionaire Drama G Anil Kapoor 3 29.95

5 Frost/Nixon Drama R Frank Langella 3 19.95

6

The Curious Case of Benjamin Button Drama G David Fincher 2 44.95

7Revolutionary Road Drama PG Kate Winslet 2 31.95

8 Crocodile Business Comedy PG13 Harris 2 69.959 Michael Clayton Action R  George Clooney 3 99.95

10No Country for Old Men Action R Javier Bardem 1 29.95

i) Display a list all movies with Price over 20 and sorted by Price.ii) Display all the movies sorted by QTY in decreasing order.iii) Display a report listing a Title, current price and replacement value for each movie as Qty * Price * 1.15iv) Display all the movies and their price whose type is Drama.v) Give the outputs for the following statements. a) SELECT AVG(Price) FROM MOVIES WHERE Price < 30; b) SELECT MAX(Price) FROM MOVIES WHERE Price > 30; c) SELECT SUM(Price * Qty) FROM MOVIES WHRE Qty< 4; d) SELECT COUNT(DISTINCT TYPE) FROM MOVIES;

6

Q.6 (a) State and algebraically verify Absorption Laws. 2

(b) Draw the logic circuit of the following Boolean expression using only NAND gates – A.B’ + (B.C)’

2

(c) Output 1s appear in the truth table for these input conditions:ABCD=0001, ABCD=0110, and ABCD=1110.What is the Sum of Products equation?

1

(d) Reduce the following Boolean expression using K-map:F(A,B,C)=∑(1,2,3,5,7)

3

Page 13 / 33

Page 14:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

Q.7 (a) How is Co-axial cable different from Optical fibre? 1

(b) Expand the following terms – (i) WLL (ii) GSM

1

(c) Differentiate between Hackers and Crackers. 1

(d) What is the difference between a computer virus and a worm? 1

(e) Green Valley Organization has set up its new center at Tatanagar for its office and sales based activities. It has four blocks as shown in the diagram below:

Center to center distances between various blocks

Number of computers

Wagon to Iris 50 m Wagon 25Iris to Ritz 150 m Iris 50Ritz to Desire 25 m Ritz 125Wagon to Desire 170 m Desire 50Iris to Desire 125 mWagon to Ritz 90 m

1. Suggest a cable layout of connections between the blocks.2. Suggest the most suitable place to house the server of this

organization. Give reasons in support of your answer.3. Suggest the placement of the following devices with justification:

a. Repeaterb. Hub/ Switch

4. The organization is planning to link its front office situated in the city in a hilly region where cable connection is not feasible, suggest an economic way to connect it with reasonably high speed.

4

KENDRIYA VIDYALAYA,GACHIBOWLI,HYDERABAD COMPUTER SCIENCE MODEL PAPER

CLASS: XIIAnswer all the questions.

1. (a) Name the header files that shall be needed for the following [1]code:

Page 14 / 33

Wagon

Ritz

Iris

Desire

Page 15:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

void main( ){char String[ ] = .Peace.;cout<<setw(2)<<String;}

(b)Illustrate the use of #define in C++ to define a macro. [2](c) Rewrite the following program after removing all the syntactical errors (if any), underlining each correction. : [2]

include<iostream.h>typedef char[40] string; void main( ){ string S=”Australia”;L=strlen(S);cout<<”String “<<S<<’ has ’<<L<<”Characters”<<endl; }

(d) Observe the following program GAME.CPP carefully, if the value NUM entered by the user is 4, choose the correct possible output(s) from the option ( i ) to ( iv ) , and justify your option. [2]

#include<stdlib.h>#include<iostream.h>void main( ){randomize( );intNum, Rndnum;cin>>Num;rndnum = random(Num) + 8;for(int N = 1; N <= Rndnum ;N++)

cout<<N<<” “;}Output Option:( i ) 1 2 3 4 ( ii ) 1 2 3 4 5 6 7 8 9 10 11( iii) 1 2 3 4 5 9( iv ) 1 2 3 4

(e) Give the output of the following program ( Assuming that all required header files are included in the program ) : [2]

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

void TRANSFER(char *s1,char *s2){ intn,j=0;for(inti=0;*(s1+i)!='\0';i++){ n=*(s1+i);if(n%2==0)*(s2+j++)=*(s1+i);} }

Page 15 / 33

Page 16:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

void main(){ char *p="ChaRlesBabBaGe",q[80];TRANSFER(p,q);cout<<q<<endl;}

(f) Find the output of the program. [3]#include <iostream.h>#include <ctype.h>int x = 10;void pass(int&a, int&c){

int x= 4;c + = x;a *= ::x;

}void main( ){

int y = 1, x =2;pass(y, ::x);cout<<x<<’:’<<y<<’:’<<::x;cout<<endl;pass(::x,x);cout<<x<<’:’<<y<<’:’<<::x;

}2. (a) What do you understand by member function? How does a member function from ordinary function? [2]

(b)Answer the questions (i) and (ii) after going through the following class : [2]class BUS{ private:charPname[30],TicktNo[20];float Fare;public:BUS( ) //function 1{ strcpy(Pname,”\0”);strcpy(TicktNo,”\0”); Fare=0; }

void Details( ) //function 2{ cout<<Pname<<endl<<TicktNo<<endl<<Fare<<endl; }BUS(char * name, char *tno, float N); //function 3BUS(BUS &F); // function 4 };

i) In OOP, what is function 3 referred to as? Also define this function.ii) Define function 4 and write about its purpose?

Page 16 / 33

Page 17:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

(c)Define a class TAXPAYER in C++ with following description : [4]Private members :

a. Name of type stringb. PanNo of type stringc. Taxabincm (Taxable income) of type floatd. TotTax of type doublee. A function CompTax( ) to calculate tax according to the following slab:

Taxable Income Tax% Up to 160000 0

>160000 and <=300000 5>300000 and <=500000 10>500000 15Public members :

A parameterized constructor to initialize all the members A function INTAX( ) to enter data for the tax payer and call function CompTax( ) to assign

TotTax. A function OUTAX( ) to allow user to view the content of all the data members.

d)Answer the questions (i) to (iv) based on the following : [4]class Student{ private : char Rollno[20], Sname[30];

protected :auto float marks; public:Student( ); void ENROL( ); void SHOW( );};class Graduate: public Student{ charFname[30];protected:unsignedint age;public:Graduate( ); void GENROL( ); void GSHOW( );};

classPgraduate: private Graduate { charMname[25]; signed int year; public:Pgraduate( );

Page 17 / 33

Page 18:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

void PGENROL( ); void PGSHOW( );};

(i) Name the base class and derived class of the class Graduate.(ii) Name the data members that can be accessed from function PGSHOW();

(iii) Name the member function which can be accessed by an object of Pgraduate class.(iii) How many bytes taken by the object of Pgraduate class?

3. (a)Write a function TRANSFERP(int ALL[ ], int N) , to transfer all the prime numbers from a one dimensional array ALL[ ] to another one dimensional array PRIME[ ]. The resultant array PRIME[ ] must be displayed on screen. [3]

(b) ) An array PP[40]32] is stored in the memory along the row with each of the elements occupying 10 bytes. Find out the memory location for the element PP[18][22], if the element PP[7][10] is stored at memory location 5000 [3]

(c) Define functions stackpush( ) to insert nodes and stackpop ( ) to delete nodes, for a linked list implemented stack having the following structure for each node. [4]

struct ticket{longticketno;char name[40];ticket *next;};

(d) Write a function in c++ which accepts an array of integers and its size as parameters and divide all those array elements by 7 which are divisible by 7 and multiply other elements by 3. [2] (e) Evaluate the following postfix notation of expression: [2]

30, 6, 4, +, /, 14, +, 4, *4. (a) Observe the program segment given below carefully and answer the question that follows : [1]

class school{ private :char name[25];intnumstu;

public:voidinschool( );voidoutschool( );intretnumstu( ){ returnnumstu; }

};

void modify(school A){ fstream INOUT;

INOUT.open(“school.dat”,ios::binary|ios::in|ios::ate);school B;

intrecread=0, found=0;

Page 18 / 33

Page 19:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

while(!found &&INOUT.read((char*)&B,sizeof(B)){ recread++;if(A.retnumstu( )= = B.retnumstu( ))

{ ____________________________//missing statement

INOUT.write((char*)&A,sizeof(A));Found=1;}

elseINOUT.write((char*)&B,sizeof(B));

}if(!found)

cout<<”\nRecord for modification does not exist”;INOUT.close( ); }

If the function modify( ) is supposed to modify a record in file school.dat with the values of school A passed to its argument, write the appropriate statement for missing statement using seekp( ) or seekg( ) , whichever needed, in the above code that would write the modified record at its proper place.

b) Write a function to count the number of vowels stored in a text file “STRINGS.TXT”. [2]

(c)Write a function to delete a record on the given model number for a TV from the binary file “TV.DAT” containing the objects of TV (as defined below) : [3]

class TV{long model;float size;charbrand [30], comp [30];public:long retmodel( ){return model; }voidInput ( ) {cin>>model>>size; gets (brand); gets (comp) ;}void Output ( ) { cout<<model<<size<<brand<<comp<<endl; } };

5. (a) What do you understand by Primary Key andCandidate Key. Explain with example. [2]

(b In a database there are two tables ‘Doctors’ and ‘Patients’ shown below- [4]Table: DoctorsDId DName OPDDays TimingD521 R. K. Sinha Monday 10 amD324 V. K.Singha Wednesday 9 amD945 P. Kumar Friday 12 pmD457 V. Prasad Saturday 10 amD125 K. Krishna Tuesday 11 amD220 M. Kumar Monday 12 pm

Table: PatientsPId Name Age Dept DateOfAdm Charges Gender DId115 Jugal 36 Nephro 2005-12-15 260 M D324621 Smita 45 Cardiology 2007-07-20 450 F D945451 Reena 14 ENT Null Null F D457

Page 19 / 33

Page 20:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

136 Kishor 64 Surgery 2001-08-28 850 M D521

i) Display details of all patients whose date of admission is after 28-01-2001.ii) Display dname,timing ,name,agedept from Doctors,Patients with their corresponding matching id.

iii)List all the names of female patients whose department is Cardiology. iv)Increase the charges of patients by Rs.50/- for all patients. (c)Give the output for the following commands: [2]i)Selectage,name from patients where charges IS null;ii)Selectavg(charges) from patients groupby gender having gender=’M’;iii)Select * from doctors where OPDDays=”Monday”;iv)Select name from patients where name like ‘R%a’;6. (a)State and prove any one DeMorgan’s Theorem. [2]

(b) Write the SOP form of a Boolean function G, which is represented in a truth table as follows :[1]A B C G0 0 0 10 0 1 10 1 0 00 1 1 01 0 0 11 0 1 01 1 0 01 1 1 1

(c ) If F(P,Q,R,S) = ∏(0,2,4,5,6,7,8,10,11,12,14) , obtain the simplified form using K-Map. [3](d) Draw a Logical Circuit Diagram for the following Boolean Expression: [2]

X’. (Y’+Z)7.(a) What is infrared technology? [1] (b) Expand the following terms: [1]

a) GSM b) TCP/IP

(c )Write one advantage and disadvantage of Star topology? [1] (d)Compare Trojan horse and worm? [1]

(e) The Rangoli Creation has set up its new center at Patna for its office & web based activities. It has four blocks of buildings as shown in the diagram below:

[4+2]

Page 20 / 33

Page 21:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

The distance between various blocks are :Block A to Block B 30 mBlock B to Block C 110 mBlock C to Block D 55 mBlock A to Block D 260 mBlock B to Block D 195 mBlock A to Block C 32 m

Number of computers in each block are :Block A 25Block B 55Block C 125Block D 15

i) Suggest the cable layout (with diagram) of connections among the blocks & technology.ii) Suggest the most suitable place to house the server, with a suitable reason.iii) Suggest the placement of the following devices with reasons : i) Repeater ii) Switch/Hubiv) The organization is planning to link its another office in the city located in the hilly region where cable connection is not feasible. Suggest an economic way to connect it with reasonably high speed. Justify your answer.f) Define Shareware?g) Give two examples of domain name.

KENDRIYA VIDYALAYA SANGATHANPRE-BOARD EXAMINATION

CLASS: - XII (COMPUTER SCIENCE)

Max Marks: - 70Question No. 1

a. What is the similarity and difference between break and continue statements?

b. Write the names of the header files to which the following belong:i) puts() ii) sin()

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

#include<iostream.h>void main(){First=10, Second=20;Jumpto(First;Second);Jumpto(second);}

Page 21 / 33

Block D

Block ABlock B

Block C

Page 22:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

void Jumpto(int N1, int N2=20){N1=N1+N2;cout>>N1>>N2}

d. Give the output of the following program:#include<iostream.h>

int g=20;void Func(int&x, int y){x=x-y;y=x*10;cout<<x<<’,’<<y<<”\n”;}void main(){int g=7;Func(g,::g);cout<<g<<’,’<<::g<<’\n’;Func(::g,g);cout<<g<<’,’<<::g<<’\n’;}

e. Find the output of the following program:#include<iostream.h>

#include<ctype.h>typedef char Txt80[80];void main(){char *PText;Txt80 Txt=”Ur2GReAt”;int N=6;PText=Txt;

while(N>=3){Txt[N]=isupper(Txt[N])?

tolower(Txt[N]):toupper(Txt[N]);cout<<PText<<endl;N--;PText++;}

}

f. The following code is from a game, which generates a set of 4 random numbers. Anuska is playing this game; help her to identify the correct option(s) out of the four choices given below as possible set of such numbers generated from the program code so that she wins the game. Justify your answer.

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

constint LOW=25;void main(){randomize();int POINT=5, Number;for(int I=1;I<=4;I++)

{Number= LOW + random(POINT);cout<<Number<<”:”;POINT--;}

Page 22 / 33

Page 23:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

}(i) 29: 26: 25: 28: (ii) 24: 28: 25: 26:(iii) 29: 26: 24: 28: (iv) 29: 26: 25: 26:

Question 2 a. What is the difference between abstract class and concrete class?

b. Answer the questions (i) and (ii) after going through the following class:

class Science{char Topic[20];int Weightage;public:Science ( ) //Function 1{strcpy (Topic, “Optics” );Weightage = 30;cout<<“Topic Activated”;}~Science( ) //Function 2{cout<<”Topic Deactivated”;}};

(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?

c. Define a class ELECTION with the following specifications. Write a suitable main ( ) function also to declare 3 objects of ELECTION type and find the winner and display the details.Private Members : Data : Candidate_Name , Party , Vote_Received

Public members : Functions : Enterdetails ( ) – to input data Display ( ) – to display the details of the candidates Winner ( ) – To display the details of the winner through the object after comparing the votes received by three candidates.

d. Answer the question (i) to (iv) based on the followingclass Book

{char Title[20];char Author[20];intnoofpages;public:void read();void show(); };

class TextBook: private Book{ intnoofchap, noofassignments;protected:int standard;public:void readtextbook();void showtextbook();};

class Physicsbook: public TextBook{char Topic[20];

Page 23 / 33

Page 24:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

public :void readphysicsbook();void showphysicsbook();};

(i) Names the members, which are accessible from the member functions of class Physicsbook.(ii) Write the names of members, which are accessible by an object of class Textbook.(iii) Write the names of all members, which are accessible by an object of class Physicsbook.(iv) How many bytes will be required by an object belonging to class Physicsbook.

Question 3 a. Write a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get the content from the array FIRST[] and odd places(1,3,5,…) of the array ALL[] should get the content from array SECOND[].Example:

If the FIRST[] array contain 30,60,90And the SECOND[] array contain 10,50,80The ALL[] array should contain 30,10,60,50,90,80

b. An array T[50][20] is stored in the memory along the column with each of the element occupying 4 bytes, find out the base address and address of element T[30][15], if an element T[25][10] is stored at the memory location 9800.

c. Write a function QUEDEL() in C++ to display and delete an element in a dynamically allocated Queue containing nodes of the following given structure:

struct NODE{ intItmemo;char Iteamname[20];NODE *Link;};

d. Define a function SWAPARR() in C++ to swap (interchange) the first row elements with the last row elements, for a two dimensional integer array passed as the argument of the function.Example: If the two dimensional array contains

5 6 3 21 2 4 92 5 8 19 7 5 8

After swapping of the content of first row and last row, it should be as follows:

9 7 5 81 2 4 92 5 8 15 6 3 2

e. Convert the following infix expression to its equivalent postfix expression showing stack contents for the conversion:

Page 24 / 33

Page 25:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

A+B*(C – D)/ E

Question 4 a. Observe the program segment given below carefully and fill in the blanks marked as Line 1 and Line 2 using fstream functions for performing the required task.#include<fstream.h>class Library{long Ano; //Ano- Accession Number of the Bookchar Title[20]; //Title- Title of the BookintQty; //Qty- Number of Books in Librarypublic:void Enter(int); //Function to enter the contentvoid Display(); // Function to display the contentvoid Buy (intTqty){Qty+=Tqty;} //Function to increment in Qtylong GetAno() {return Ano;}};void BuyBook(long BAno, intBQty)//BaNo->Ano of the book purchased//QBty-> Number of books purchased{fstream File;File.open("STOCK.Dat", ios :: binary|ios::in|ios::out);int Position=-1;Library L;while (Position==-1 &&File.read((char*)&L,sizeof (L)))if(L.GetAno()==BAno){L.Buy(BQty); //To update the number of BooksPosition = File.tellg( )-sizeof(L);//Line1: To place the file pointer to the required position;_________;//Line 2: To write the object L on to the binary file_________;}if (Position == -1)cout<< "No updation done as required Ano no found.";File.close();}

b. Write a function COUNT_TO( ) in C++ to count the presence of a word “to” (independent word only) in a text file “NOTES.TXT” Example:If the content of the file “NOTES.TXT” is a follows:

It is very important to know that Smoking is injurious to health.Let us take initiative to stop it.

The function COUNT_TO( ) will display the following message:Count of – to- in file : 3

Note : In the above example, ‘to’ occurring as a part of word stop is not considered.

c. Write a function in C++ to search for a Toy having a particular Toy Code (Tcode) from a binary file “TOY.DAT” and display its details (Tdetails), assuming the binary file is containing the objects of following class: class TOYSHOP

{intTcode; //Toy Code char Tdetails[20];public:

Page 25 / 33

Page 26:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

intRTcode() {return Tcode;}void AddToy(){cin>>Tcode;gets(Tdetails);}void DisToy(){cout<<Tcode<<Tdetails<<endl;}};

Question No. 5

a. What are DDL and DML Commands? Give one example of each.

b. Consider the following tables Stationary and Consumer. Write SQL commands for the statement (i) to (iv) and output for SQL queries (v) to (viii):

Table: StationaryS_ID StationaryName Company Price

DP01 Dot Pen ABC 10

PL02 Pencil XYZ 6

ER05 Eraser XYZ 7

PL01 Pencil CAM 5

GP02 Gel Pen ABC 15

Table: ConsumerC_ID ConsumerName Address S_ID

01 Good Learner Delhi PL01

06 Write Well Mumbai GP02

12 Topper Delhi DP01

15 Write & Draw Delhi PL02

16 Motivation Banglore PL01

(i) To display the details of those consumers whose Address is Delhi.

(ii) To display the details of Stationary whose Price is in the range of 8 to 15. (Both Value included)

(iii) To display the ConsumerName, Address from Table Consumer, and Company and Price from table Stationary, with their corresponding matching S_ID.

(iv) To increase the Price of all stationary by 2.(v) SELECT DISTINCT Address FROM Consumer;(vi) SELECT Company, MAX(Price), MIN(Price), COUNT(*)

from Stationary GROUP BY Company;(vii) SELECT Consumer.ConsumerName,

Stationary.StationaryName, Stationary.Price FROM Strionary, Consumer WHERE Consumer.S_ID=Stationary.S_ID;

(viii) Select StationaryName, Price*3 From Stationary;

Question 6 a. Verify the following algebraically(A’+B’).(A+B)=A’.B+A.B’

Page 26 / 33

Page 27:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

b. Draw a logical Circuit Diagram for the following Boolean Expression:A.(B+C’)

c. Write the equivalent Canonical Sum of Product for the following Product of SumExpression: F(X,Y,Z)= (1,3,6,7)

d. If F(a,b,c,d) =(0,1,3,4,5,7,8,9,11,12,13,15), obtain the simplified form using K-Map.

Question 7 a. What was the role of ARPANET in the Computer Network?

b. a) 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.

(i) KMph (ii) Mbps (iii) MGpsc. Write the full forms of the following:

(i) FTP (ii) FSF

d. “Vidya for All” is an educational NGO. It is setting up its new campus at Jaipur for its web based activities. The campus has four buildings as shown in diagram below:

Center to center distances between various buildings as per architectural drawings (in meters) is as follows:

Main Building to Resource Building 120mMain Building to Training Building 40mMain Building to Accounts Building 135mResource Building to Training Building 125mResource Building to Accounts Building 45mTraining Building to Accounts Building 110m

Expected number of Computers in each building is as follows:Main Building 15Resource Building 25Training Building 250Accounts Building 10

b) Suggest a cable layout of connection between the buildings.c) Suggest the most suitable place(i.e building) to house the

server of this NGO. Also provide a suitable reason for your suggestion.

d) Suggest the placement of the following devices with justification:

e) Repeaterf) Hub/Switchg) The NGO is planning to connect its International office

situated in Delhi. Which out of following wired communication links, will you suggest for very high speed

Page 27 / 33

Page 28:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

connectivity?i) Telephone Analog Line ii) Optical Fibreiii) Ethernet Cable

e. What are cookies?.

f. What is telnet?

CLASS - XIISUBJECT – COMPUTER SCIENCE

Duration : 3 Hours Maximum Marks : 70

General Instructions :(i)All questions are compulsory.

(ii) Programming Language C++.

1. (a) Define any two features of OOPs. Also give suitable example in C++. 2(b) Name the header file(s) that shall be needed for successful compilation of the following C++ code. 1

void main(){

int a[10];for(int i=0;i<10;i++){cin>>a[i];if(a[i]%2==0)

a[i]=pow(a[i],3);else

a[i]=sqrt(a[i]);if(a[i]>32767)

exit(0);}

getch(); }

c) Rewrite the following code after removing syntactical error(s), if any. Underline each correction: 2#include<iostream.h>class Exams { charE_name[30], S_name[30];

IntS_nos = 100;float marks[3];

public: Exams ( ) { };

void input( ){ strcpy(E_name, “Computer Science “);strcpy(S_name, “Amen Singhania “);cin>>marks;}void output( ){cout<<”Name “<<S_name<<endl;

Page 28 / 33

Page 29:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

cout<<”S_Name”<<E_name<<endl;cout<<”Number “<<S_nos<<endl;

}};

void main( ){ Exams E;

E.input;E.display; }

d) Write the output of the following code: 2 # include<iostream.h> # include<ctype.h>

void manipulate( char string[], int&len) {for(int i=0; string[i]!=’\0’;i++){if (isupper(string[i]))string[i]= string[i]-2; len++;elseif (isupper(string[i]))string[i]=string[i+2]; −−len;elsestring[i]=’@’;

} }void main( ){ char word[]= “FuNUnliMiTEd!! “;int length=strlen(word);

manipulate (word, length );cout<<”Word “<<word<<”@”<<”Length”<<length;}e) Find the output 3 #include<iostream.h>void in( int x, int y, int&z)

{ x+=y;y--;z*=(x-y);

}void out( int z, int y, int&x){ x−= y;

y++;z/=(x+y);

}void main( ){

int a= 20, b=30, c=10;in (a, c, b);cout<<a<<”#”<<b<<”#”<<c<<”#”<<endl;out (b, c, a);cout<<a<<”@”<<b<<”@”<<c<<”@”<<endl;

in (a, b, c);cout<<a<<”$”<<b<<”$”<<c<<”$”<<endl;

}f) Chose the correct alternative from the options (i)- (iv). Justify your answer. 2 #include<iostream.h> #include<stdlib.h> #define Getval (N) ((N%2 = =0)? N+1:N+2)

void main( ) { randomize( );

intnum= random(3)+3;for(int I= num ; I<=num+2 ;I++)cout<<Getval(I)<<’@’;

}

Page 29 / 33

Page 30:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

Options:a) 3@5@7@b) 7@7@9@c) 7@9@9@d) 7@9@11@2 (a)What do you understand by Data Encapsulation and Data Hiding? Also, give a suitable C++ code to illustrate both. 2 b) Answer questions 1 and 2 after going through the following class: 2

class game { char name[20]; int players;

public:game (int, char*); // MODULE 1game (game &g1); // MODULE 2~game( ); // MODULE 3

};1. Define MODULE 2 outside the class.2. What is MODULE 3 known as? Which OOP concept do they imply?

C) Define a class Applicants with the following information: 4Private members

a. rollno of type intb. Name of type character with size as 30c. Category of type character (‘G’ for general , ‘S’ for Schedule caste , ‘T’ for Schedule Tribe)d. Fees of type Float

Public members A constructor to initialise category as a blank character and fees as 0. A function to input Roll number , name and category of the student, and to calculate fees of the

student on the basis of category entered as :o Category ‘G’ then Fees is 12000o Category ‘S’ then Fees is 4000o Category ‘T’ then Fees is 3500

A function to display all the information of the applicant.

D) Answer Questions 1 to 4 after going through the following code: 4class drama {

char dname[20];int Dduration;protected:char dactors[10][20];public:void enterdrama( );void displaydrama( ); };

classrealityshow { char rname[15];int Rduration;protected:char Rparticipants[15][20];public:void enterreality ( );void dispreality( ); };

classtvprog : public drama, private realityshow, public news{ char chnlgrp[20];

Float pkgcost;public:void enterprog( );void dispprog( ); };

1. Write the names of all members accessible from dispprog( ) of class tvprog.2. Write name of all data members accessible from object of class tvprog.3. Calculate size of an object of class tvprog.4. Write the order for the call of the constructors when object of class tvprog is declared.

Page 30 / 33

Page 31:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

Q3 a) Write a user defined function in C++ to search a students record from the given Array of structure usingbinary search technique. Assume the array is sorted in descending order of the roll number. Assume the following definition :

struct Student{ char name[20];

long rollno;};

b) An array X[5] [20] is stored in the memory along the column with each element occupying 4 bytes of memory. Calculate the address of an element X [2] [15] if the element X [3] [10] is stored at the address 2200. 3 c) Write a function in C++ to insert an element in a dynamically allocated Queue containing the names of the countries. Give necessarydeclarations. 4 d) Write a user defined function intALTERSUM(int B[], int N, int M) in C++ find and return the sum of elements from all alternate elements of a 2-D array from B[0] [0]. 2

EXAMPLE: 5 4 3 6 7 8 1 2 9The function should add 5,3,7,1,9 and return 25.e) Evaluate the following postfix expression showing the stack content: 2False, True, NOT, OR, True, False, AND, OR.

Q4a Observe the program segment given below and fill the gaps as staements1 and statement 2 using seekp() and tellg() functions. [1]

# include<fstream.h>class employee{ inteno; char Ename[20];public:

int counter();};

int employee : : counter (){ fstream File;

File.open(“EMP.DAT”, ios: : binary | ios : : in);_______________ // statement 1int bytes =____________ // statement 2int count =bytes /sizeof(employee);File .close();return count;}

b. Write a function in C++ to count the words “This” and “These” present in a text file “NOTES.TXT”. 2

c) Given a binary file BOOK.DAT containing records of the following type: 3class user

{ char unmae[20], status; // A active I inactive. int uid;public:void readdetails( );voids howdetails( );char getstatus( ) { return status };void setstatus( char s ) { status=s; }; int getid( )

{ return id };};

Write a function which changes the status of all users with previous status as ‘I’ to ‘A’ .5. (a) What do you understand by Degree and Cardinality of a table? 2(b) Write SQL commands for (a) to (f) and write output for (g) on the basis of Teacher relation given below: 6 Table: Teacher

No. Name Age Department DateofJoin Salary Sex1 Jugal 34 Computer 10/01/97 12000 M

Page 31 / 33

Page 32:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

2 Sharmila 31 History 24/03/98 20000 F3 Sandeep 32 Maths 12/12/96 30000 M4 Sangeeta 35 History 01/07/99 40000 F5 Rakesh 42 Maths 05/09/97 25000 M6 Shyam 50 History 27/06/98 30000 M7 Shiv Om 44 Computer 25/02/97 21000 M8 Shalakha 33 Maths 31/07/97 20000 F

a) To show all information about the teacher of history department.b) To list the names of female teachers who are in Hindi department.c) To list names of all teachers with their date of joining in ascending order.

d) To display teacher’s Name, Salary, Age for male teacher only. e) To count the number of teachers with Age >23.

f) To insert a new row in the Teacher table with the following data:9,”Vijay”, 26,”Computer”, {13/05/95}, 35000,”M”

(g) Give the output of the following SQL queries (i) Select count (Distinct Department) from Teacher;(ii) Select AVG (Salary) from Teacher where DateofJoin<{12/07/96};(iii) Select SUM (Salary) from Teacher whereDateofJoin<{12/07/96};(iv) Select MAX(Age) from Teacher where Sex=”F”;

6. (a) State and verify Distribution Law in Boolean Algebra . 2(b) Draw a Logical Circuit Diagram for the following Boolean Expression: 1

X’. (Y’+Z)(c) Convert the following Boolean expression into its equivalent Canonical Product of Sum Form (POS):

A.B’.C+A’.B.C+A’.B.C’ 2 (d) Reduce the following Boolean expression using k-map: 3

F(A,B,C,D)=∑(0,1,2,4,5,8,9,10,11)

7. (a) What is the difference between LAN and WAN? 2

(b) Expand the following terms: 3 a) GSM b) CDMA c) XML d) URL e) TCP/IP f) FTP(c) Name any two cyber crimes. 1(d) Knowledge Supplement Organization has set up its new centre at Mangalore for its office and web based activities. It has four buildings as shown in the diagram below: 4

Center to center distance between various buildings Number of ComputersAlpha to Beta 50m Alpha 25Beta to Gamma 150m Beta 50Gamma to Lambda 25m Gamma 125

Alpha to Lambda 170m Lambda 10

Beta to Lambda 125mAlpha to Gamma 90m

i) Suggest a cable layout of connections between the buildingsii) Suggest the most suitable place (i.e. building) to house the server of this organization with a

suitable reason.iii) Suggest the placement of the following devices with justification:

i. Repeaterii. Hub/Switch

Page 32 / 33

Alpha Gamma

BetaLamb

da

Page 33:  · Web viewWrite a Get1From2( ) function in C++ to transfer the content from two arrays FIRST[] and SECOND[] to array ALL[]. The even places (0,2,4,…) of array ALL[] should get

iv) The organization is planning to link its front office situated in the city in a hilly region where cable connection is not feasible, suggest an economic way to connect it with reasonably high speed?

Page 33 / 33