Top Banner
COMPUTER SCIENCE – REVISION AISSCE 2011-12 TOPIC: POINTERS,STRINGS, STRUCTURES, LIBRARY FUNCTION Q 1 WHAT WIIL BE OUTPUT OF FOLLOWING PROGRAM? #include<iostream.h> #include <conio.h> void main() { clrscr(); int sum(int(*)(int) ,int); int square(int); int cube(int); cout<<sum(square,4)<<endl; cout<<sum(cube,4)<<endl; getch(); } int sum(int(*ptr)(int k),int n) { int s=0; for(int i=1;i<=n;i++) { s+=(*ptr)(i); } return s; } int square(int k) { int sq; sq=k*k; return k*k; } int cube(int k) { return k*k*k; } Q.2 Find the output of the following program? #include<iostream.h> #include<conio.h> #include<string.h> class state { char *statename; int size; public: state(){size=0;statename=new char[size+1];} state (char *s) { size=strlen(s);statename=new char[size+1]; strcpy(statename,s); } void display() { cout<<statename<<endl;} Page 1 of Pages 21
22

Comp Sci Rev

Apr 06, 2018

Download

Documents

skm1577
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 1/22

COMPUTER SCIENCE – REVISION AISSCE 2011-12

TOPIC:POINTERS,STRINGS, STRUCTURES, LIBRARY FUNCTION

Q 1 WHAT WIIL BE OUTPUT OF FOLLOWING PROGRAM?#include<iostream.h>

#include <conio.h>

void main()

{clrscr();

int sum(int(*)(int),int);

int square(int);int cube(int);

cout<<sum(square,4)<<endl;

cout<<sum(cube,4)<<endl;getch();

}

int sum(int(*ptr)(int k),int n)

{

int s=0;for(int i=1;i<=n;i++)

{s+=(*ptr)(i);

}

return s;}

int square(int k)

{ int sq;sq=k*k;

return k*k;

}int cube(int k){

return k*k*k;

}Q.2 Find the output of the following program?

#include<iostream.h>

#include<conio.h>#include<string.h>

class state

{ char *statename;

int size;public:

state(){size=0;statename=new char[size+1];}

state (char *s){ size=strlen(s);statename=new char[size+1];

strcpy(statename,s);

}void display()

{ cout<<statename<<endl;}

Page 1 of Pages 21

Page 2: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 2/22

void replace(state&a, state &b)

{size=a.size+b.size;

delete statename;statename=new char[size+1];

strcpy(statename, a.statename);

strcat(statename,b.statename);}

};

void main()

{ clrscr();char *temp="Delhi";

state state1(temp), state2("Mumbai"), state3("Nagpur"), s1,s2;

s1.replace(state1,state2);s2.replace(s1,state3);

s1.display();

s2.display();getch();

}

Q3. Find the output of the following program?

#include <iostream.h>struct Game

{char Magic[20];int Score;

};

void main(){

Game M={"Tiger",500};

char *Choice;Choice=M.Magic;

Choice[4]='P';

Choice[2]='L';M.Score+=50;cout<<M.Magic<<M.Score<<endl;

Game N=M;

 N.Magic[0]='A';N.Magic[3]='J'; N.Score-=120;

cout<<N.Magic<<N.Score<<endl;

}Q4. In the following program, if the value of N given by the user is 20, what maximum and minimum

values the program could possibly display?

#include <iostream.h>

#include <stdlib.h>void main()

{

int N,Guessnum;randomize();

cin>>N;

Guessnum=random(N-10)+10;cout<<Guessnum<<endl;

}

Page 2 of Pages 21

Page 3: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 3/22

Q5. Find out errors in the following program:-

class number {

int x=10;

float y;number(){ x=y=10;}

public:

number(number t)

{x=t.x; y=t.y;

}

~ (){ cout<<"Object destroyed ";}}

main()

{number a1, a2(a1);

}

Q6. Find the output of the following program:

#include<iostream.h>void main()

{

int list[5];

*list=5;

for(int i=1; i<5;i++)

*(list+i)= *(list+i-1)*i;

cout<<”\n”;

for(i=0;i<5;i++)

cout<<””<<*(list+i);

}

Q7. What will be the output of the following program:

#include <iostream.h>

  void Secret(char Str[ ])

  { for (int L=0;Str[L]!='\0';L++);

for (int C=0;C<L/2;C++)

if (Str[C]=='A' || Str[C]=='E')

Str[C]=Str[L-C-1];

else

{ char Temp=Str[C];

Str[C]=Str[L-C-1];

Str[L-C-1]=Temp;

}

}

void main()

{ char Message[ ]="PreboardExam";

Secret(Message);

Page 3 of Pages 21

Page 4: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 4/22

cout<<Message<<endl;

}

Q8. Find the output of the following program:

# include <iostream.h>

# include <conio.h>

# include <stdlib.h>

void main ()

{

char serial[] = {'A', 'B', 'C', 'D'};

int number[] = { 2, 6, 7, 3};

clrscr();

randomize();

cout << " The winner is : ";

cout << serial [random(3)];

for (int i = 0; i < 4; i++)

cout << number[sizeof(int) + random(2) - 1 ];

getch();}

Outputs:

(i) The winner is : A2776

(ii) The winner is : D6766

(iii) The winner is : B6767

(iv) The winner is : C3672

Q9. (A) What do you mean by static variable? Explain with help of example.(B) Write the header files to which the following functions belong:

(i) getc ( ) (ii) isalnum ( ) (iii) scanf ( ) (iv) getxy ( )

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

#include<string.h>

#include<ctype.h>void Change(char Msg[], int Len)

{for(int Count=0;Count<Len;Count++)

{if(islower(Msg[Count]))

Msg[Count]=toupper(Msg[Count]);

else if(isupper(Msg[Count]))Msg[Count]=tolower(Msg[Count]);

else if(isdigit(Msg[Count]))

Msg[Count]=Msg[Count]+1;

Page 4 of Pages 21

Page 5: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 5/22

else Msg[Count]=’*’;

} }

void main(){

char Message[]=”2011 World Cup Ahead”;

int Size=strlen(Message);Change(Message,Size);

cout<<Message<<endl;

for(int C=0,R=Size-1;C<=Size/2;C++,R--)

{char Temp=Message[C];

Message[C]=Message[R];

Message[R]=Temp;}

cout<<Message<<endl;

}Q11. Study the following program and select the possible output from it:. Also justify your 

answer.

#include<iostream.h>

#include<stdlib.h>

const int Max=3;void main( )

{randomize( );

int Div;

Div=1+random(Max);for(int N=1;N<5;N++)

{

cout<<100%Div<<”#”;}

}

i) 0#0#0#0#ii) 1#1#1#1#iii) 2#2#2#2#

iv) 3#3#3#3#

Q12. What will be the output of the program?

#include<iostream.h>

class base{ public:

void display()

{

cout<<"It is a base class "<<endl;}

};

class derived: public base{

 public:

void display(){ cout<<"It is a derived class "<<endl;}

};

Page 5 of Pages 21

Page 6: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 6/22

main()

{

derived ob1;ob1.display();

}

TOPIC

OOPS FUNDAMENTAL, CLASSES, CONSTRUCTOR & DESTRUCTORS

Q13. Define a class named Tour in C++ with following description?

Private members:

tcode integer (Ranges 6 - 10)adults, children, distance integer 

totalfare float

AssignFare( ) A function which calculates and assign the value to data member  totalfare as follows:-

- For adults Fare Distance

Rs. 500 >=1500

And fare get reduced by 25% if distance is < 1500.

- For ChildrenFor every child a fixed Rs. 50 is charged as fare.

Public members:

• A constructor which initialized initialize all data members with 0

• Function EnterTour() to input the values of the data members tcode, adults, children and

call to AssignFare function.

• Function ShowTour() to print all the details of object of Travel type.

Q14. Define a class named Admission in C++ with following description?

Private members:

admno integer (Ranges 10-1500)

name string of 20 characterscls integer  

fees float

Public members:A constructor which initialized admno with 10, name with “NULL”, cls with 0 & fees with 0

Function getdata() to read the object of Admission type.

Function putdata() to print the details of object of admission type.

Function draw_nos() to generate the admission no. randomly to match with admno and displaythe detail of object.

Q15. Define a class in C++ with following description:

Private Membersa. A data member Flight number of type integer 

 b. A data member Destination of type stringc. A data member Distance of type float

d. A data member Fuel of type float

e. A member function CALFUEL() to calculate the value of Fuel as per the followingcriteria

Distance Fuel

<=1000 500

Page 6 of Pages 21

Page 7: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 7/22

more than 1000 and <=2000 1100

more than 2000 2200

Public Members

• A function FEEDINFO() to allow user to enter values for Flight Number, Destination,

Distance & call function CALFUEL() to calculate the quantity of Fuel

• A function SHOWINFO() to allow user to view the content of all the data members

Q16. Define a class PhoneBill in C++ with the following descriptions. [4]

Private members:

CustomerName of type character arrayPhoneNumber of type long

No_of_units of type int

Rent of type intAmount of type float.

 

calculate( ) This member function should calculate the value of amount as Rent+ cost for theunits.Where cost for the units can be calculated according to the following conditions.

No_of_units Cost

First 50 calls FreeNext 100 calls 0.80 @ unit

Next 200 calls 1.00 @ unitRemaining calls 1.20 @ unit

Public members:* A constructor to assign initial values of CustomerName as “Raju”, PhoneNumber as

259461, No_of_units as 50, Rent as 100, Amount as 100.* A function accept ( ) which allows user to enter CustomerName, PhoneNumber, No_of_units

And Rent and should call function calculate ( ).

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

Q17.(a) What do you understand by Polymorphism? Give a suitable example of the same.(b)Answer the questions (i) and (ii) after going through the following class:

class Match

{

int Time; public:

Match()

//Function 1{

Time=0;

cout<<"Match commences"<<end1;

}void Details() //Function 2

{

cout<<"Inter Section Basketball Match"<<end1;}

Match(int Duration) //Function 3

{Time=Duration;

cout<<"Another Match begins now"<<end1;

Page 7 of Pages 21

Page 8: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 8/22

}

Match(Match &M) //Function 4

{Time=M.Duration;

cout<<"Like Previous Match "<<end1;

}};

(i) Which category of constructor - Function 4 belongs to and what is the purpose of using it?

(ii) Write statements that would call the member Functions 1 and 3.

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

Class testmeout

{ int rollno; public:

~testmeout() //Function 1

{ cout<<rollno<<” is Leaving examination hall”<<endl;}

testmeout() //Function 2

{ rollno=1;

cout<<rollno<<” is appearing for examination “<<endl;

}testmeout(int n, char name[]) //Function 3

{ rollno=n;cout<<name<<” is in examination hall”<<endl;

}

testmeout(testmeout & t);//function 4void mywork() //Function 5

{ cout<<rollno<<” is attempting questions “<<endl;

}};

i) In object oriented programming, what is Function 1 referred as and when does it get invoked?ii) In object oriented programming, what is Function 2 referred as and when does it get invoked?iii) In object oriented programming, what is Function 3 referred as and when does it get invoked?

iv) Write a statement so that function 3 gets executed? Complete the definition of function 4

Q19 (a) When the object is passed to the function the copy of the object is made. Does constructor and

destructor are called for the object copy?(b) Answer the questions (i) and (ii) after going through the following program:

class Basketball

{ int Time;public:

Basketball() //Function 1

{Time = 0;

cout<<”Match commences “<<endl;

}void Details() //Function 2

{

Page 8 of Pages 21

Page 9: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 9/22

cout<<”Inter Section Basketball Match”<<endl;

}

Basketball(int Duration) //Function 3{

Time = Duration;

cout<<”Another match begins now”<<endl;}

Basketball(Basketball &M) //Function 4

{

Time = M.Duration;Cout<<”Like Previous Match”<<endl;

}

};(i) Which category of constructor – Function 4 belongs to and what is the purpose of using it?

(ii) Write statements that would call the member Functions 1 and 3.

Q20. (a) What is Function Overloading? Give an example in C++ to illustrate the same.

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

#include<iostream.h>

#include<string.h>

class AirIndia{

char flno;int Nop;

 public:

AirIndia() //function1{

strcpy(flno,” ”); Nop=0; }

AirIndia( chat *str,int n) //function2{

strcpy(flno,str); Nop=n; }

void input //function3{cin>>flno; cin>>Nop; }

~AirIndia() //function4

{cout<<”counter closed”<<endl;

}

};(i) In Object Oriented Programming, which concept is illustrated by Function1 and Function2

together? Write the statement to call these functions.

(ii) What is the scope of two data members of the class AirIndia? What does the scope of data

members depend upon?

TOPIC: INHERITANCE & FILE HANDLING

Q21. Consider the following and answer the questions given below:

class MNC

{char Cname[25];

 protected:

Page 9 of Pages 21

Page 10: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 10/22

char Hoffice[25];

 public:

MNC();char Country[25];

void EnterDate ( );

void DisplayData ( );};

class Branch:public MNC

{

long NOE:char Ctry[25];

 protected:

void Association( ); public:

Branch( );

void Add( );void Show( );

};

class Outler: public Branch

{

char State[25]; public:

Outlet( );void Enter ();

void Output();

};i) Which class’s constructor will be called first at the time of declaration of an object of 

class Outlet?

ii) How many bytes an object belonging to class Outlet require?iii) Name the member function(s), which are accessed from the object(s) of class Outlet.

iv) Name the data member(s), which are accessible from the object(s) of class Branch

Q22. Consider the following and answer the questions given below:class Regular 

{

char Collegecode[10];public:

void InRegular();

void OutRegular();};

class Distance

{protected:

char StudyCentreCode[5];public:

void InDistance();

void OutDistance();};

class Course : public Regular, Distance

{char Code[5];

float fees;

Page 10 of Pages 21

Page 11: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 11/22

int duration;

public:

void InCourse();void OutCourse(); 4

};

(i) Which type of inheritance is shown in the above example?(ii) Write names of all the member functions accessible from OutCourse function of class

Course.

(iii) Write name of all the members accessible through an object of the class Course.

(iv) Is the function InRegular() accessible inside the function InDistance()? Justify youranswer.

Q23. Answer the questions (i) to (iii) based on the following code:

class furniture{

char Type;

char Model[10];public:

furniture();

void Read_fur_details( );void Disp_fur_detailsO;

};

class sofa : public furniture{

int no_of_seats;

float cost_of_sofa;

public:void Read_sofa_details( );

void Disp_sofa_details( );

};

class office: private sofa{

int no_of_pieces;char delivery_datel10l;

 public:

void Read_office_details( );

void Disp_office_details( );};

void main( )

{ office MyFurniture; }

i. Mention the member names which are accessible by MyFurniture declared in main ()function. (1) 

ii. What is the size of MyFurniture in bytes? (1) 

iii. Mention the names of functions accessible from the member functionRead_office_details () of class office. (2) 

Q24. Answer the questions (i) to (IV) based on the following code: [4]

class CUSTOMER 

Page 11 of Pages 21

Page 12: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 12/22

{

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: public CUSTOMER, protected SALESMAN{

char voucher_no[10];char sales_date[8];

 public:

SHOP( );void sales_entry( );

void sales_detail( );

};(i) Write the names of data members 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 members which are accessible from member functions of class SHOP.(iv) How many bytes will be required by an object belonging to class SHOP?

Q25. Given a binary file PHONE.DAT, containing records of the following structure type. 3class Phonlist

{

char Name[20] ;char Address[30] ;

char AreaCode[5] ;

char phoneNo[15] ;

public :void Register();

void show();

int CheckCode(char AC[ ]){

return strcmp(Areacode, AC) ;

}} ;

Page 12 of Pages 21

Page 13: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 13/22

Write a function TRANSFER () in C++, that would copy all those records which are having AreaCode

as “DEL” from PHONE.DAT to PHONBACK.DAT.

Q26 (a) Observe the program segment given below carefully and fill in the blanks marked as statment1

and statement2 using write() and remove() functions for performing the required task.#include<fstream.h>

class Emp

{

int Eno;char name[20];

 public :

//function which will delete the data of a specific employeevoid deleteRec(int Eid);

};

void Emp::deleteRec(int Eid){

fstream file;

file.open(“Emp.dat”,ios::in|ios::out|ios::binary);

ofstream ofile(“temp.dat”);

while(file){

file.read((char *)this,sizeof(eobj));if(this->Eno !=Eid)

 _________________//statement1

} ________________//statement 2

rename(“temp.dat”,”emp.dat”);

} b) Write a function to reverse only those lines ends with vowel character from a text file poem.txt.

Q27. Write a function in C++ to update the SUPPLIER NAME for a given SNO from a binary file“SUPP.DAT”, assuming the binary file is contained the objects of the following class:[3]

class SUPPLIER {

int SNO;

char SUPP_NAME [20]; public:

int SUPPNO ( ) { return SNO; }

void Enter ( ) { cin >> SNO; gets (SUPP_NAME); }

void Display ( ) { cout << SNO <<SUPP_NAME ; }};

Q28. Observe the program segment given below carefully, and answer the question that follows:

class PracFile

{int Pracno;

char PracName[20];

Page 13 of Pages 21

Page 14: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 14/22

int TimeTaken;

int Marks;

 public:void EnterPrac( );

void ShowPrac( ); // function to display PracFile details

int RTime( ) // function to return TimeTaken{ return TimeTaken; }

void Assignmarks(int M) // function to assign Marks

{Marks=M }

};void AllocateMarks ( )

{

fstream File;File.open(“Marks.Dat”,ios::binary | ios::in | ios::out) ;

PracFile P;

int Record=0;while(File.read((char*)&P,sizeof(P)))

{

if(P.Rtime( )>50)

P.Assignmarks(0);

elseP.Assognmarks(10)

------------------------ // statement 1------------------------ // statement 2

Record + +;

}File.close( );}

If the function AllocateMarks( ) is supposed to allocate mark for the records in the file Marks.Dat based on their value of the member TimeTaken. 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.

Q29. Assume that a text file named TEXT1.TXT already contains some text written into it, write a

function named vowelwords( ), that reads the file TEXT1.TXT and create a new file named

TEXT2.TXT, which shall contain only those words from the file TEXT1.TXT which don’t startwith an uppercase vowel(i.e ‘A’,’E’,’I’,’O’,’U’).

For example if the file TEXT1.TXT contains 2

Carry Umbrella and Overcoat When it Rains

then the file TEXT2.TXT shall contains

Carry When it Rains

Q30. Given a binary file APPLY.DAT, containing records of the following class Applicant typeclass Applicant

{

char A_Rno[10];char A_Name[30];

int A_Score;

 public:void Enrol( )

{

Page 14 of Pages 21

Page 15: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 15/22

gets(A_Rno);

gets(A_Name);

cin>>A_Score;}

void Status( )

{cout<<setw(20)<<A_Rno;

cout<<setw(20)<<A_Name;

cout<<setw(10)<<A_Score<<endl;

}int ReturnScore( )

{ return A_Score;}

};

Write a function in C++, that would read contents of file APPLY.DAT and display Students

whose A_Score is below 70.

TOPIC: DATA STRUCTURES & ARRAYS

Q31. Given two arrays of integers A and B of sizes M and N respectively. Write a function namedMIX() which will produce a third array named C, such that the following sequence is followed :

All even numbers of A from left to right are copied into C from left to right.All odd numbers of A from left to right are copied into C from right to left

All even numbers of B from left to right are copied into C from left to right.

All odd numbers of B from left to right are copied into C from right to leftA, B and C are passed as arguments to MIX().

e.g. : A is {3,2,1,7,6,3} and B is {9,3,5,6,2,8,10}, the resultant array C is {2,6,6,2,8,10,5,3,9,3,7,1,3}

Q32. Suppose an array P containing float is arranged in ascending order. Write a user defined function

in C++ to search for one float from P with the help of binary search method. The function should

return an integer 0 to show absence of the number and integer 1 ti show presence of the number inthe array. The function should have the parameters as (1) an array (2) the number DATA to besearched (3) number of element N.

Q33. Write a function in C++ which accepts an integer array and its size as arguments / parameters

and assign the elements into a two dimensional array of integers in the following format :

If the array is 1, 2,3,4,5,6 If the array is 1,2,3

The resultant 2D array is given below The resultant 2D array is

1 2 3 4 5 6 given below

1 2 3 4 5 0 1 2 31 2 3 4 0 0 1 2 0

1 2 3 0 0 0 1 0 0

1 2 0 0 0 01 0 0 0 0 0

Q34. Write a function in C++ to perform a PUSH operations on a dynamically allocated stack containing

real number?

Page 15 of Pages 21

Page 16: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 16/22

struct Node

{

float data; Node * next;

};

Q35. Each node of a STACK containing the following information, in addition to required pointer field:

Roll no. of the student

Age of the student.

Gve the structure of node for the linked stack in question.TOP is a pointer to the topmost node of the STACK. Write the following function:

PUSH() – TO push a node in to the stack which is allocated dynamically.

POP() – Te remove a node from the stack and to release the memory.

Q36. Write a function in C++ which accepts a 2D array of integers and its size as arguments anddisplays the elements which lies on diagonals.

[Assuming the2D array to be a square matrix with odd dimensions , i.e 3x3, 5x5,7x7, etc ]

Example if the array content is

5 4 3

6 7 81 2 9

Output through the function should beDiagonal one : 5 7 9

Diagonal two : 3 7 1 .

Q37. Write a function in C++ which accepts a 2D array of integers and its size as arguments and

displays the elements of the middle row and the elements of middle column.

Example if the array content is3 5 4

7 6 9

2 1 8Output through the function should be:Middle row: 769 Middle column: 5 6 1

Q38. Define functionstackpush( ) to insert nodes and stack pops ( ) to delete nodes . for a linked listimplemented stack having the following structure for each node

struct Node

{Char name [ 20 ]

int age ;

Node * link ;

};class stack {

 Node * top ;

public:Stack ( ) { top = null ;} ;

void stackpush ( );

void stack pop ( ) ;}

Page 16 of Pages 21

Page 17: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 17/22

Q39

a) An array A[10][20] is stored in the memory along the column, with each of the element occupying 2

 bytes, find out the memory location for element A[2][5], if an element A[5][10] is stored at thememory

location 3020.

 b) Convert the expression (TRUE && ! FALSE)|| (FALSE && TRUE) to postfix expression. Show thecontents of the stack at every step.

Q40.

a) 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 [5][2] is stored

at the address 1500.

 b) Evaluate the following postfix notation of expression:10 20 + 25 15 - * 30 /

Q41. A 2-d array defined as A[4..7, -1..3] requires 2 words of storage space for each element

stored in row major order. Calculate the address of A[7,0] and base address if the location

of A[6,2] as 126.

Q42. Consider the following portion of a program, which is implemented as linked list of 

library. Write the definition of function PUSH( ), to insert a new node in the stack anddefinitions of function POP(), to delete a node from the stack 

struct Library {

int id;char name[20];

Library *Link; };

TOPIC: BOOLEAN ALGEBRA

Q43. (a) State and algebraically verify Absorption Laws.

(b)Write the POS form of a Boolean Function F, which is represented by the following

truth table:

A B C F

0 0 0 0

0 0 1 1

0 1 0 1

0 1 1 1

1 0 0 1

1 0 1 0

1 1 0 0

1 1 1 1

Q44. (a) Obtain the simplified form of the Boolean Expression using K’ Map:

F( x , y , z, w) = ∑ (0,2,4,5,8,9,12,13,15)

(b)Represent OR operation using NAND gates only.

Page 17 of Pages 21

Page 18: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 18/22

 

Q45. a) State and verify Associative Law.

b) Write the equivalent expression for the following Logic Circuit:

Q46.a) Convert the following Boolean expression into its equivalent Canonical Product of Sumform(POS) : A.B’.C+A’.B.C+A’.B.C’

b) Reduce the following Boolean Expression using K-Map:

F(P,Q,R,S)=∑(0,3,5,6,7,11,12,15)

Q47. a) Write the equivalent Boolean expression for the logic circuit given below

 b) Write the canonical P-O-S expression for the following S-O-P expression

F(a,b,c) = ∑(1,2,5,6)

c) Reduce the following expression using K-map F(a,b,c,d) = п(0,1,2,4,5,6,8,9,10,14)

Q48.

a. State and verify Associative Law. b. Write the equivalent expression for the following logical circuit:

c. Express P+Q ’R in POS form.

d. Reduce the following Boolean expression using K-Map:F(P, Q, R, S) = π (0,3,5,6,7, 11, 12, 15)

Q49.(a) State and verify De Morgan’s Laws algebraically.

(b) Write the equivalent Boolean Expression for the following Logic Circuit.

Page 18 of Pages 21

Page 19: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 19/22

Q50.

Reduce the following Boolean Expression using K-Map:

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

TOPIC: DATABASE AND SQL

Q51.(A) Explain Cartesian Product of two relations?

(B) Define the terms Tuple and Attribute

Q52

(A) Explain the terms : Candidate Key, Primary Key and Alternate Key

(B) What is Foreign key? Explain with a suitable Example.

Q53

(A) What do you understand by the terms Cardinality and Degree of the table?

(B) Differentiate between : (i) WHERE and HAVING (ii) DML and DDL

Q54

Write the SQL query commands based on following table

Table : Book 

Book_id Book name Author_name Publisher Price Type Quantity

C0001 Fast Cook Lata Kapoor EPB 355 Cookery 5

F0001 The TearsWilliamHopkins First Publi. 650 Fiction 20

T0001 My First c++

Brain &

Brooke FPB 350 Text 10

T0002

C++ Brain

works

A.W.

Rossaine TDH 350 Text 15

F0002 Thunderbolts Anna Roberts First Publ. 750 Fiction 50

Table : issued 

Book_Id Quantity Issued

T0001 4

C0001 5F0001 2

Write SQL query for (a) to (f)

(a) To show book name, Author name and price of books of First Pub. Publisher (b) To list the names from books of text type

(c) To Display the names and price from books in ascending order of their prices.

(d) To increase the price of all books of EPB publishers by 50.

Page 19 of Pages 21

Page 20: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 20/22

(e) To display the Book_Id, Book_name and quantity issued for all books which have been issued

(f) To insert a new row in the table issued having the following data. ‘F0003’, 1

(g) Give the output of the followingi. Select Count(*) from Books

ii. Select Max(Price) from books where quantity >=15

iii. Select book_name, author_name from books where publishers=’first publ.’iv. Select count(distinct publishers) from books where Price>=400

Q55.

Q.19. Table: EmployeesEmpid Firstname Lastname Address City

010 Ravi Kumar Raj nagar GZB

105 Harry Waltor Gandhi nagar GZB

152 Sam Tones 33 Elm St. Paris

215 Sarah Ackerman 440 U.S. 110 Upton

244 Manila Sengupta 24Friends street New Delhi

300 Robert Samuel 9 Fifth Cross Washington

335 Ritu Tondon Shastri Nagar GZB

400 Rachel Lee 121 Harrison St. New York  

441 Peter Thompson 11 Red Road Paris

  Table: EmpSalaryEmpid Salary Benefits Designation

010 75000 15000 Manager  

105 65000 15000 Manager  

152 80000 25000 Director  

215 75000 12500 Manager  

244 50000 12000 Clerk  

300 45000 10000 Clerk  

335 40000 10000 Clerk  

400 32000 7500 Salesman

441 28000 7500 salesman

Write the SQL commands for the following :

(i) To show firstname,lastname,address and city of all employees living in paris

(ii) To display the content of Employees table in descending order of Firstname.

(iii) To display the firstname,lastname and total salary of all managers from the tables

Employee and empsalary , where total salary is calculated as salary+benefits.

(iv) To display the maximum salary among managers and clerks from the table Empsalary.

(v) Give the Output of following SQL commands:

(i) Select firstname,salary from employees ,empsalary where designation =

‘Salesman’ and Employees.empid=Empsalary.empid;(ii) Select count(distinct designation) from empsalary;

(iii) Select designation, sum(salary) from empsalary group by designation having

count(*) >2;(iv) Select sum(benefits) from empsalary where designation =’Clerk’;

Q56.(a) Compare any two Switching techniques.

Page 20 of Pages 21

Page 21: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 21/22

(b) What do you mean by a router and switch?

(c) How is Freeware different from Free Software?

(d) Expand the following: a) FLOSS b) HTML c) GNU d) ARPANET

Q57.

a) Define the term Bandwidth. Give any one unit of Bandwidth. b) Which of the following is not a Client Side script:

(i) VB Script (ii) Java Script (iii) ASP (iv) PHP

(c) What is a topology? Write short note on Bus topology.

(d) Expand the following terms with respect to Networking:(i) PPP (ii) GSM (iii) HTTP (iv) XML

Q58.(a) Write one advantage and disadvantage of Bus Topology.

(b) Expand the following terms with respect to Networking.

i) WLL ii) PHP(c) Differentiate between Freeware and shareware?

(d)Explain the terms: (i) GNU (ii) OSS (iii) CDMA (iv) GPRS

(e)Differentiate between Hackers and Crackers?

Q59.Knowledge Supplement Organization has set up its new center at Mangalore for its office and web based

activities. It has 4 blocks of buildings as shown in the diagram below:

Center to center distances between various blocks

Number of Computers

Black A to Block B 50 m

Block B to Block C 150 m

Block C to Block D 25 m

Block A to Block D 170 mBlock B to Block D 125 m

Block A to Block C 90 m

Page 21 of Pages 21

Black A 25

Block B 50

Block C 125

Block D 10

Block

A Block

C

Bloc

k

BBlock

D

Page 22: Comp Sci Rev

8/3/2019 Comp Sci Rev

http://slidepdf.com/reader/full/comp-sci-rev 22/22

1) Suggest a cable layout of connections between the blocks.

2) Suggest the most suitable place (i.e. block) to house the server of this organization with a

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

(i) Repeater (ii) Hub/Switch

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

speed?

Q60.

(a) What are cookies.(b) Define the term Bandwidth. Give unit of Bandwidth.

(c) Expand the following terminology : (i) NSF (ii) ARPANET

(d) Distinguish between star and Bus topology

Page 22 of Pages 21