You are on page 1of 6

Class XII Subject - Computer Science Half Yearly Examination

Time allowed : 3 Hours Note (i) All questions are compulsory. (ii) Programming Language : C++ 1. (a) (b) (c)

Maximum Marks : 70

Write the names of the header files to which the following belong : 1 (i) random( ) (ii) isupper(), What is variable scope? What is the difference between Local and Global scope? Explain with an example. 2 In the following program, if the value of Guess entered by the user is 65, what will be the expected output(s) from the following options (i), (ii), (iii) and (iv)? 2 #include <iostream.h> #include <stdlib.h> void main() { int Guess; randomize(); cin>>Guess; for (int I=1;I<=4;I++) { New=Guess+random(I); cout<<(char)New; } } (i) ABBC (ii) ACBA (iii) BCDA (iv) CABD 2

(d)

(e)

Write the output of the following program: #include<iostream.h> int func (int &x, int y=10) { if(x%y==0) return ++x; else return y--; } void main() { int p=20,q=23; q=func(p,q); cout<<p<< <<q<<endl; p=func(q); cout<<p<< <<q<<endl; q=func(p); cout<<p<< <<q<<endl; }

What will be the output of the following program: void main()


int b; char bboy[10]; cout<<endl; bboy[0]=s,bboy[1]=h,bboy[2]=r; bboy[3]=u,bboy[4]=t,bboy[5]=i; len(bboy); } void len(char boy[10]) { int l; l=strlen(boy); cout<<l; for (int i=0;i<=l;i++) { char a = toupper(boy[i]); cout<<a; } {

(f) Define a class Bank to represent the bank account of a customer with the following specification 4 Private Members: - Name of type character array(string) - Account_no of type long - Type_of_account ( S for Saving Account, C for current Account) of type char - Balance of type float Public Members: A constructor to initialize data members as follows - Name NULL - Account_no 100001 - Type_of_account S - Balance 1000 A function NewAccount() to input the values of the data members Name, Account_no, Type_of_account and Balance with following two conditions Minimum Balance for Current account is Rs.3000 Minimum Balance for Saving account is Rs.1000 A function Deposit() to deposit money and update the Balance amount. A function Withdrawal() to withdraw money. Money can be withdrawn if minimum balance is as >=1000 for Saving account and >=3000 for Current account. A function Display() which displays the contents of all the data members for a account. 2. (a) Give the output of the following program 2 #include<iostream.h> void main() { int a,b,store=0,c; a=6; for (b=2;b<=a-1;b++) { c=a%b; if (c!=0) store = store + b; } cout<<store; return 0; } Write a function in C++ which accepts an integer array and its size as arguments/parameters and assigns the elements in to two dimensional array of integers in the following format: 4 If the array is 1,2,3,4,5,6 ,then the resultant 2D array should be : 123456 123450 123400 123000 120000 100000 000000

(b)

(c)

What is the benefit of declaring a data member as protected? 2 (d) Answer the questions (i) and (ii) after going through the following class: 2 class serial { int serialcode; char title[20]; float duration;

int no_of_episode; public: serial() //function 1 { duration = 30; no_of_episode = 10; } serial(int d, int noe) //function 2 { duration = d; no_of_episode = noe; } serial( &s1) // function3 {} ~serial() // function 4 { cout<<Destroying Object<<endl; } }; (i) Complete definition of function 3 (ii) Give example how function1 and function 2 get executed when object is created. (e)
3. (a) What is key in RDBMS? What are different key constraints? 2

(b) Write SQL commands for the statements (i) to (iv) and give outputs for SQL queries (v) to (viii): on the basis of the table 6 BOOKS Book_Id F0001 F0002 T0001 T0002 C0001 Book_Name The Tears Thunderbolt MyFirstC++ C++Brain Fast Cook Author_name William Hopkins Anna Roberts Brain & Brooke A.W. Rossaine Lata Kapoor Publishers First Publ. First Publ. EPB TDH EPB Price 750 700 250 325 350 Type Fiction Fiction Text Text Cookery Quantity 10 5 10 5 8

ISSUED Book_Id F0001 T0001 C0001 i. ii. iii. iv. v. vi. Quantity_Issued 3 1 5

To show Book name, Author name and Price of books of EPB Publishers. To list the names from books of Fiction type. To display the names and price of the books in descending order of their price. To increase the price of all books of First Publ. Publishers by 50. To display the Book_Id, Book_Name and Quantity_Issued for all books which have been issued. (The query will require contents from both the tables.) To insert a new row in the table Issued having the following data:

vii. viii.

F0002, 4. Give the output: a. SELECT COUNT (DISTINCT Publishers) FROM Books; b. SELECT SUM(Price) FROM Books WHERE Quantity > 5; c. SELECT Book_Name, Author_Name FROM Books WHERE Price <500;

d. SELECT COUNT (*) FROM Books; (e) An array P[20][30] is stored in the memory along the column with each of the element occupying 4 bytes, find out the memory location for the element P[5][15], if an element P[2][20] is stored at the memory location 5000. 4

4.

(a) 2

What are the first and last values of i output by this loop?

n = 10; i = 0; while (++i < n) { cout<<i<<endl; } (b) Write a function in C++ to find sum of rows from a two dimensional array. (c) Find the output of the following program: 2 #include <iostream.h> #include <ctype.h> void Encrypt(char T[]) { for (int i=0;T[i]!='\0';i+=2) if (T[i]=='A' || T[i]=='E') T[i]='#'; else if (islower(T[i])) T[i]=toupper(T[i]); else T[i]='@'; } void main() { char Text[]="SaVE EArtH";//The two words in the string Text //are separated by single space Encrypt(Text); cout<<Text<<endl; } (d)Write a function in C++ which accepts an integer array and size as arguments and sort all the elements in ascending order using selection sort technique. 3 5. a. Answer the questions (i) to (iv) based on the following code: 4

class livingbeing { char specification[20]; int averageage; public: void read(); void show(); }; class ape : private livingbeing { int no_of_organs, no_of_bones; protected: int iq_level; public: void readape(); void showape();

}; class human : public ape { char race[20]; char habitation[30]; public: void readhuman(); void showhuman(); };
(i) Name the members which can be accessed from the member functions of class human. (ii) Name the members, which can be accessed by an object of class human. (iii) What will be the size of an object (in bytes) of class human. (iv) Name the class(es) that can access read() declared in livingbeing class.

(b) Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays elements which are exactly two digit number. 3
If 2D array is

Output is 14 25

3 9 14 129 2 25 146 1431 1924 32 45 327 11 455 28 18


32 45 11 28 18

(c) An array K[5][5] is stored in the memory with each element occupying 4 bytes of space. Assuming the base address of K to be 1000, compute the address of K[2][4], when the array is stored : 4 (i) Row wise (ii) Column wise (g) Write a user defined function in C++ which intakes one dimensional array and size of array as argument and find sum of elements which are even. 3 If 1D array is 10 , 2 , 3 , 4 , 5 , 16 , 17 , 23 Then even numbers in above array is 10 , 2 , 4 , 16 Sum = 10 + 2 + 4 + 16 = 32 Output is 32 6. (a) (b) State and algebraically verify Absorbtion Laws. Write the equivalent Boolean Expression for the following Logic Circuit 2 2

U V

(c) Write the SOP form of a Boolean function G, which is represented in a truth table as follows: 1 P Q R G 0 0 0 0 1 1 0 0 1 1 0 0 0 1 0 1 0 1 0 0 1 0 1 0

1 1 F(U,V,W,Z)=(0,1,2,4,5,6,8,10)

1 1

0 1

1 1 3 3

(d) Reduce the following Boolean Expression using K-Map:


(e) If F(w,x,y,z) = (0,3,4,5,6,7,8,11,12,15), obtain the simplified form using K-Map.