You are on page 1of 13

Examination Papers, 2000

[All India]
Maximum Marks : 70
Note.

Duration : 3 Hours

All the questions are compulsory.
Programming Language : C++

1. (a) Illustrate the use of this pointer with the help of an example.
(b) Name the header file, to which following built- in function belong :
(i) strcpy()
(ii) isdigit()
(iii) log()
(iv) puts()
(c) Will the following program execute successfully ? If not, state the reason(s).

2
2
2

#include<iostream.h>
void main()
{
int x, sum = 0;
cin<<n;
for (x=1, x<100, x+=2)
if x % 2= =0
sum+=x;
cout<<"SUM=">>sum;
}

(d) Give the output of the following program segment(Assume all required header files are included in
the program) :
2
char *s = "GOODLUCK";
for (int x = 0;x<strlen(s)–1 ; x>=0; x––)
{
for ( int y=0; y<=x; y++) cout<<s[y];
cout<<endl;
}

(e) Write the output of the following program :

3

#include<iostream.h>
int a=3;
void demo(int x, int y, int &z)
{
a += x+y;
z = a+y;
y += x;
cout<<x<<y<<z<<endl;
}
void main()
{
int a=2, b=5;
demo(: :a, a, b);
cout<<: : a <<a<<b<<endl;
demo(: : a , a, b );
}

(f) Write a function sum() in C++ with two arguments, double x and int n. The function should return
a value of type double and it should find the sum of the following series :
4
1 + x/1! + x3/2! + x5/3! + x7/4! + x9/5! + … + x2n-1/n!

Examination Paper

1

to point to the current object being operated upon. a pointer this has been used to print the value of an even though the pointer has not been declared anywhere. { cin>>a.h (c) The correct program is : # include<iostream.h (ii) isdigit() : ctype. x<100. (a) While manipulating objects for user programs.h (iii) log() : math.x+=2) if( x%2 == 0) sum += x. } Correction 1 : Undefined symbol ‘n’ Correction 2 : Illegal structure operation cin<<n Correction 3 : for statement missing ( for x = 1.h (iv) puts() : stdio. (b) (i) strcpy() : string. int n. } void display() { cout<<"\n a = "<<this->a. Whenever a member function of an object is called. for (x = 1.x+=2) Correction 4 : If statement missing if x%2 == 0 Correction 5 : Illegal structure operation cout>> “SUM = ” >>sum. public: void read().sum = 0. the compiler places the address of the object in pointer this before invoking the function. cout << "SUM = " << sum. (d) The output is : GOODLUCK GOODLUC GOODLU GOODL GOOD GOO GO G (e) The output of the given program is : 3510 8210 81020 2 Together with ® Computer Science (C++) – XII . For example : class xyz { int a. In the above class xyz. } }.h> main() { int x. C++ maintains an internal pointer called this. cin>>n. x < 100.Ans.

s = s + t / (fact(i)). marks. }. name. i++. protected : int c. d. int i. } double sum(double x.j). } 2. b.(f) The function is : int fact(int num) { double prod=1. (a) What is the use of a constructor function in a class ? Give a suitable example of a constructor function in a class. s = 1. int n) { double s.j = 1. y. public : void getvalA(). displayinfo() function to display all data members on the screen you should give function definitions. while(i<=num) { prod=prod*i. Examination Paper 3 . 2 (b) Define a class report with the following specification : 4 Private members : adno 4 digit admission number name 20 characters marks an array of 5 floating point values average average marks obtained getavg() to compute the average obtained in five subjects Public members : readinfo() function to accept values for adno. (c) Consider the following and answer the questions given below : 4 class A { void anyval().i++) { t = pow(x. } return(prod). int i=1. j = j + 2. double t=0. void putvalA().i<n. for(i=1. protected : int x. class B : protected A { int a. } return(s). and invoke the function getavg().

public: void read(). cout << "Enter the student no. (ii) Name all the protected members of class B. float marks[5]. }. class C : public B { int P. (b) The class is : class report { int adno. 4 Together with ® Computer Science (C++) – XII . For example : # include<iostream.b. }. protected : int q. float average. cin >> adno. b = 0. }. void getval( ). } public : void read_info( ). It is used to initialize the data members of the class. which are accessible by the objects of class C. public : void putvalB( ).void getvalB. xyz() //Constructor { a = 0. float getavg( ) { return ((marks[0] + marks[1] + marks[2] + marks[3] + marks[4])/5). void displayinfo( ). } }. (iv) Name the data members. (i) Name all the member functions. which are accessible from member functions of class C. (iii) Name the base class and derived class of class B. gets(name). Ans. : ". cout << "Enter the student name : ". public : void showval( ). char name[20]. (a) Constructor function is required in classes to create the object. void report :: read_info( ) { clrscr( ).h> class xyz { int a. cout << "Enter marks in five subject : ".

const N = 10.TRUE. TRUE. OR. getvalB(). int Z[M+N].I++) cout << "Marks in " << (I+1) << " subject " << marks[I] << endl. 4 Ans. Show the contents of stack after execution of each operation : 2 TRUE. 3 What is the pre-condition for applying binary algorithm ? 1 Differentiate between a LIFO list and FIFO list.10] requires 8 bytes of storage. which are accessible by the objects of class C are putval() and showval().10][1. Write a user defined function in C++ to produce third array Z by merging arrays X and Y in descending order. (a) // Function to manipulation of two arrays X and Y for a merging in third array Z with // descending order.i++) { cout << "\t". void merge() { clrscr().i<N. y. int i. FALSE. OR. cout << "Student No. Examination Paper 5 .N and M+N respectively. const M = 10.. when the array DATA is stored (i) Row Wise (ii) Column wise. AND Give the necessary declarations of a queue containing integers. cout << "Average : "<<average<<endl. (ii) Protected member of class B : c..k. for(i=0.I++) cin >> marks[I]. } cout << "\n\tEnter the second array in descending order\n".i<M. p. cout << "\n\tEnter the first array in descending order\n". Suppose X. c. 4 An array DATA[1. for(int I =0. for(i=0. Z are arrays of integers of size M.I<5. } (c) 3.I<5. average = getavg( ). d. If the base address of array DATA is 1500.j. The queue is to be implemented as a linked structure. x. } void report :: displayinfo( ) { clrscr(). The numbers in array X and Y appear in descending order. d. Y.for (int I =0. determine the location of DATA [4][5]. NOT. int Y[N]. int X[M]. y (iii) Base class : class A Derived class : class C (iv) The data members are : x. : " << adno << endl cout << "Student Name : " << name << endl. cin >> X[i]. (a) (b) (c) (d) (e) (f) (i) The member functions. q. FALSE. 1 Evaluate the following postfix expression using a stack.i++) { cout << "\t". Write a user defined function in C++ to delete an integer from the queue. OR.

k+=1. for(k=0. i+=1. // Merging the first and second array while((i<M)&&(j<N)) { if(X[i]<Y[j]) { Z[k]=Y[j]. } clrscr().j=0. j+=1.k++) cout<<“\n”<<Z[k]. j+=1. k+=1.cin>>Y[i]. } while(j<N) { Z[k]=Y[j]. cout << "\n\tThe merged arrays are ". } (b) Given : Base = 1500 W = 8 bytes N = 10 M = 10 I=4 J=5 To find Row Major Order The formula is applied : VAL[I][J]= B +((I-1)* N+(J-1))*W = 1500+((4-1)* 10 + (5-1))* 8 = 1500 + (34)*8 = 1500 + 272 = 1772 (Ans. k+=1.k=0. } else { Z[k]=X[i]. i+=1.k<(M+N).) To find Column Major Order The formula is applied : VAL[I][J] = B +((J-1) * M +(I-1)) * W 6 Together with ® Computer Science (C++) – XII . } } while(i<M) { Z[k]=X[i]. k+=1. } i=0.

= 1500 +((4-1) + 10 * (5-1)) *8 = 1500 +(43) * 8 = 1500 + 344 = 1844 (c) The precondition for the binary search is that the array should be sorted in advance. the element inserted first will delete first. In this data structure. E. e.g.g stack. (e) In the given expression true and false are operand and AND. The FIFO stands for First In First Out. (i) true true (ii) false true false (iii) true true false true (iv) false true false true false (v) NOT NOT is operator POP one operand NOT false = true PUSH true on stack true false true true (vi) OR OR is operator POP TWO operand Evaluate : true OR true = true PUSH true on stack true false true (vii) true true false true true (viii) OR OR is operator POP TWO operand Evaluate : true OR true = true PUSH true on stack true false true (ix) OR OR is operator POP TWO operand Evaluate : true OR false = true PUSH true on stack true true (x) AND OR is operator POP TWO operand Examination Paper 7 . the elements inserted in the last is deleted first. In this data structure. queue. NOT and OR are operator. (d) The LIFO stands for Last In First Out.

10. float salary. }. ifstream. Ans. 1 4 Give function definitions to do the following : (i) Write the objects of employee to a binary file. } else { temp = front. (b) // Program to demonstrate the file operation # include <fstream.h> #include <process.Evaluate : true AND true = true PUSH true on stack true (f) // Declares a queue structure struct node { int data.} }. node *link. if (front == NULL) { cout << "Queue Empty ". char name [20]. (a) The stream classes are fstream.} void show( ) {cout<<code<<name<<salary<<endl.000 and Rs. // Private data members 8 Together with ® Computer Science (C++) – XII . int &val) { node *temp.h> #include <stdio.h> #include <conio.} float retsal( ) {return salary. (b) Consider the following class declaration : class employee { int code.h> class employee // Class declaration { int code.000. val = -1. front = front->link. (a) Name the stream classes supported by C++ for file input and output.h> #include <string. } return (front). } 4. // Function body for delete an integer from the queue node *del_Q(node *front. ofstream. val = temp->data. 20. delete temp. (ii) Read the objects of employee from a binary file and display all the objects on the screen where salary is between Rs. clrscr(). temp->link = NULL. public : void input( ) {cin>>code>>name>>salary.

// Creates the data file int n. } }.show().open("EMP. empfile. cin >> n.close(). // General functioin to operate the class member function void data_read(). sizeof(employee)).oepn("EMP. ios::beg).dat". } void data_read() { employee emp.eof()) // If there is no record. // Reads the record one-by-one tsalary = emp. ios::in|ios::binary). // Display the output through the member function if (empfile.dat". cout << "Enter how many records U want to enter ". i. // Transfer the salary into tsalary if (tsalary >= 10000 && tsalary <= 20000) // Checks the condition emp. while (empfile) { empfile. sizeof(employee)). } 5. return 0. Define Second Normal Form. it terminates the loop exit(0).retsal().read((char *)&emp. int main() { data_read(). } float retsal() { return salary. (a) Differentiate between SQL commands DROP TABLE and DROP VIEW. for (i=0.seekg(0. clrscr(). empfile.input(). if (!empfile) cout << "File does not exists". empfile. // Declares the employee object fstream empfile. i<n. void data_show(). i++) { emp. // Declares the employee object for read operation float tsalary = 0.write((char *)&emp. empfile.0 // A temporary salary fstream empfile. ios::app|ios::out|ios::binary). } empfile. data_show().close(). 2 Examination Paper 9 . } void data_show() { employee emp. public : // Public member functions void input() { cin>>code>>name>>salary. } empfile.char name[20]. } void show() { cout << code<<name<<salary<<endl. float salary.

“COMPUTER SC “. (iv) Select COUNT(DISTINCT SUBJECT) from GRADUATE. 75. 300. 10 Together with ® Computer Science (C++) – XII . (a) DROP TABLE DROP VIEW 1. (iii) SelectAVG(STIPEND) fromGRADUATE whereAVERAGE >= 65. 1 (d) To count the number of students who are either PHYSICS or COMPUTER SC graduates. 1 (e) To insert a new row in the GRADUATE table : 1 11. (g) Assume that there is one more table GUIDE in the database as shown below : 2 Table : GUIDE MAINAREA ADVISOR PHYSICS VINOD COMPUTER SC ALOK CHEMISTRY RAJAN MATHEMATICS MAHESH What will be the output of the following query : SELECT NAME. This command drops a table from a 1. 1 (f) Give the output of following SQL statement based on table GRADUATE : 2 (i) Select MIN(AVERAGE ) from GRADUATE where SUBJECT= “PHYSICS”. The condition for dropping a table is 2. “KAJOL”. STIPEND. listing NAME. SUBJECT and amount of stipend received in a year assuming that the STIPEND is paid every month. GUIDE WHERE SUBJECT = MAINAREA. that it must be an Empty table. Ans. This command drops a view (Virtual table with no database physically. ADVISOR FROM GRADUATE. (ii) Select SUM(STIPEND) from GRADUATE where DIV = 2.Write SQL commands for (b) to (f) and write the outputs for (g) on the basis of table GRADUATE : Table : GRADUATE 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 SNO NAME STIPEND SUBJECT AVERAGE DIV 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 1 KARAN 400 PHYSICS 68 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 2 DIVAKAR 450 COMPUTER SC 68 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 3 DIVYA 300 CHEMISTRY 62 2 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 4 ARUN 350 PHYSICS 63 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 5 SABINA 500 MATHEMATICS 70 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 6 JOHN 400 CHEMISTRY 55 2 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 7 ROBERT 250 PHYSICS 64 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 8 RUBINA 450 MATHEMATICS 68 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 9 VIKAS 500 COMPUTER SC 62 1 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 10 MOHAN 300 MATHEMATIC 57 2 12345678901234567890123456789012123456789012345678901234567890121234567890123456789012345678901212345 (b) List the names of those students who have obtained Div 1 sorted by NAME. Deletion of rows is not necessary. physical data) 2. 1 (c) Display the report.

Y. 2 (b) Prove (A+B). 300. “COMPUTER SC”. 13. Y.75. STIPEND. This states that : (i) (A + B)' = A'. (c) SELECT NAME. 2 (c) Obtain simplified from for a Boolean expression 3 F(X. SUBJECT . (a) State DeMorgan’s Laws. STIPEND *12 FROM GRADUTE. 15) using K Map method. Z.Second Normal Form: A table is said to be in 2NF if it is in 1N and each non-key attribute is functionally dependent on the entire key. W) = Σ(0. the truth table for which is given below :1 A B C F 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 0 1 1 1 1 Ans. 9.B)' A' B' A' + B' 0 0 1 1 1 1 1 0 1 0 1 1 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 Examination Paper 11 . 4. “KAJOL”.B (A. (f) (i) 63 (ii) 1000 (iii) 450 (iv) 4 (g) NAME ADVISOR KARAN VINOD DIVAKAR ALOK DIVYA RAJAN ARUN VINOD SABINA MAHESH JOHN RAJAN ROBERT VINOD RUBINA MAHESH VIKAS ALOK MOHAN MAHESH 6.B.B)' = A' + B' A B A.1). (A'+B'+C)algebraically.1 (f) Express in the POS form. (a) DeMorgan’s Law : This is the most powerful law of Boolean algebra. Verify them using truth table. 1.C). (A+B + C').B' (ii) (A. the Boolean function F(A. 5. 1 (e) Draw the circuit diagram for the Boolean function F(X. 12. (d) SELECT COUNT(*) FORM GRADUATE where (SUBJECT = “PHYSICS” OR SUBJECT = “COMPUTER SC”). (e) INSERT INTO GRADUATE VALUES (11. 8.Z) = (X'+Y)(Y'+Z) using NOR gates only. (A'+C) = (A+B+C). (A'+B+C). (d) Give the truth table for a Full – adder. (b) SELECT NAME FROM GRADUATE WHERE DIV = 1 ORDER BY NAME. 7.

7.B') [X. Repeater is used to regenerate data and voice signals when they become weaker before reaching destination node. 13. Z) = (X' + Y)(Y' + Z) using NOR gates as : X' (X' + Y) Y (X' + Y)(Y'+Z) Y’ Z (f) 7. 9. 1. 5. 4. Z. Y. 2 What is the difference between MAN and WAN ? 1 Sometimes the signals on the Internet are become weaker before reaching the destination node. 12. W) = S(0. Y. 12 Together with ® Computer Science (C++) – XII . Repeater read the incoming signals and amplifies it and transmit to another segment of the network. (a) (Y' + Z) (A + B + C)(A + B' + C)(A' + B + C)(A' + B' + C) What are Repeaters ? 1 Name the device used to connect a computer to an analog telephone line.C')(A' + C + B.X' = 0] = (A + B + C)(A + B + C')(A' +C + B)(A' + C + B') = (A + B + C)(A + B + C')(A' + B + C)(A' + B' + C) (c) F(X. 15) ZW XY 00 01 11 10 00 1 1 01 1 1 1 11 1 1 10 1 1 1 F = Z' + ZW (d) The truth table for a Full-adder : A B C SUM CARRY 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 (e) Circuit diagram for the Boolean function F(X.S = (A + B)(A' + C) = (A + B + C.(b) L. (a) (b) (c) (d) Ans.H. 1 Briefly mention two advantages and two disadvantages of Star topology in network.

But there is no upperlimit in WAN. Examination Paper 13 .. These provide easy occurs for service or re-configuration of the network.e. (iii) MAN provide means for internetworking of local networks.The star topology has a number of concentration point i.(b) MODEM (c) Advantages of Star Topology : (i) Ease of service . up to one small city or town. (ii) Central node dependency : If the central node fails the network get failed.e. i. at the central node or at intermediate wiring closets. (ii) WAN operate at much higher speed than MAN. Disadvantages of Star Topology : (i) Long cable length : Because each node in star topology is directly connected to the center. (ii) One device per connection : In star topology. (d) The difference between WAN and MAN are : (i) In MAN the distance between the nodes is limited. failure of a single connection typically involves disconnecting one node from an other.. the star topology requires a large quantity of cable.