Beruflich Dokumente
Kultur Dokumente
5. 6. 7. 8.
Illustrate the use of #define in C++ to define a macro. /* CBSE 2006 */ What do you mean by compile time and run time error? Give one example of each? Difference between syntax and semantic error? Explain with an example? What do you understand by syntax error, logical error & run time error? Explain with example. /*CBSE 2007 */ 9. Differentiate between break and continue statements. 10. How is entry controlled loop different from exit controlled loop? Explain with one example of each? 11. What do you mean by scope and lifetime of a variable? 12. What is the purpose of using a typedef command in C++. Explain with suitable example. /* CBSE 2008 */ 13. What is the difference between a typedef name and a reference name in C++? Explain with suitable example. 14. Difference between i) structure & array ii) structure & class. 15. What is variable scope? What is the difference between Local and Global scope? Explain with an example. 16. What are Nested Structures? Give an example. /* CBSE 2006 */ 17. What is the difference between #define & const? Explain through example. /* CBSE 2008 */ 18. Name the Header file(s) that shall be needed for successful compilation of the following C++ code? i) void main() { char st[20]; gets(st); if(isaplha(st[0]) cout<<Starts with alphabet; else cout<<strlen(st); } ii) void main( ) /*CBSE 2008 */ { char String[ ] = Peace; cout << setw(2)<<String; } iii) void main( ) { char String[20]; gets(String); strcat(String,CBSE); puts(String); } /*CBSE 2007 */
iii) #include<iostream.h> /* CBSE 2005 */ const int Multiple 3; void main( ) { Value = 15; for(int Counter = 1;Counter = <5;Counter ++, Value -= 2) if(Value%Multiple = = 0) cout<<Value * Multiple; cout<<end1; else cout<<Value + Multiple <<endl; } iv) #include<iostream.h> void main( ) { int P[ ]={90,10,24,15};Q,Number=4; Q=9; for[int I=Number-1;I>=0,I--] switch(I) /* CBSE 2003 */
/* CBSE 2008 */
/* CBSE 2003 */
/* CBSE 2001 */
/* CBSE 2000 */
/* CBSE 1998 */
/* CBSE 2005 */
/* CBSE 2007 */
/* CBSE 2005 */
//If Num=5
2. What do you understand Polymorphism? Give an example illustrating its use in a C++ program. /* CBSE 2004 */ 3. How does function overloading implement polymorphism?
Computer Science, Class XII, 2010-11 Chapter No.4 (Classes and Objects)
1. How does a class enforce data hiding, abstraction and encapsulation? 2. What is the significance of private, protected and public access specifiers in a class? 3. Differentiate between public and private visibility modes in context of Object Oriented Programming using a suitable example illustrating each. /* CBSE 2008*/ 4. Illustrate the use of inline function in C++ with help of an example. /* CBSE 2006 */ 5. What is the global class and local class? Explain with suitable example. 6. What is static data member and static member function? Give suitable example using C++ code to illustrate them. 7. What do you mean by static data members of a class? Explain the characteristics of a static data member. /* CBSE 2002 */ 8. Define the term Data Hiding in the context of Object Oriented Programming. Give a suitable example using a C++ code to illustrate the same. /*CBSE 2005,2010 */ 9. Define the term Data Encapsulation in the context of Object Oriented Programming. Give a suitable example using a C++ code to illustrate the same. /*CBSE 2005,2010 */ 10. Rewrite the following program after removing the syntactical errors (if any). Underline each correction. i) #include [iostream.h] class PAYITNOW { int Charge; PUBLIC: void Raise(){cin>>Charge;} void Show{cout<<Charge;} }; void main() { PAYITNOW P; P.Raise(); Show(); } ii) #include <iostream.h> /* CBSE 2010*/ class FLIGHT { long FlightCode; char Description[25]; public void AddInfo( ){cin>>FlightCode; gets(Description);} void ShowInfo{cout<< FlightCode<<:<<Description<<endl;} }; void main() { FLIGHT F; AddInfo.F(); ShowInfo.F(); }
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
10
11
7. Differentiate between default & parameterized constructor with suitable example. 8. What is a copy constructor? What do you understand by constructer overloading? /*CBSE 1998*/ 9. Explain the concept constructor overloading with a suitable example. 10. Answer the questions (i) and (ii) after going through the following class: class player {int health; int age; public: player() { health=6; age=18 } player(int s, int a) {health =s; age = a ; } player( player &p) { } ~player() { cout<<Memory Deallocate; } };
13
14. Define a class Society with the following specifications. Data members : Private Members : society_name char (30) house_no integer no_of_members integer flat char(10) income float Member Functions: Public members: A constructer to assign initial values of society_name as Mahavir Nagar, flat as A Type, house_no as 56, no_of_members as 6, income as 50000. input( ) to read data members. alloc_flat( ) To allocate flat according to income income >=50000 - Flat A Type income >=25000 and income <50000 - Flat B Type income <25000 - Flat C Type show( ) to display all details. 15. Define a class Play in C++ with the following specifications: /*CBSE 2003*/ Private members of class Play ?? Playcode integer ?? Playtitle 25 character ? Duration float ? ?v?v Noofscenes integer
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
14
16. Defne a class WEAR in C++ with following description : /*CBSE 2008*/ Private members : code string Type string Size integer material string Price real number A function calprice( ) that calculates and assign the value of price as follows : For the value of material as WOOLEN Type Price(Rs.) ------------------Coat 2400 Sweater 1600 For material other than WOOLEN the above mentioned price gets reduced by 30%. Public members : A constructor to get initial values for code, Type & material as EMPTY & size and price with 0. A function INWEAR( ) to input the values for all the data members except price which will be initialized by function calprice( ). Function DISPWEAR( ) that shows all the contents of data members
17. Define a class Employee in C++ with the following specification: Private Members: ename an array of char of size[50] ( represent employee name) deptname an array of char of size[20] ( represent department name) salary integer ( represent total salary of an employee) bonus float CalBonus() This function calculate the total bonus given to an employee according to following conditions Deptname Bonus Accounts 4 % of salary HR 5% of salary IT 2% of salary Sales 3% of salary Marketing 4% of salary Public Members: Constructor to initialise ename and deptname to NULL and salary and bonus to 0. A function read_info to allow user to enter values for ename, deptname,salary & Call function CalBonus() to calculate the bonus of an employee. A Function disp_info() to allow user to view the content of all the data members.
15
16
17
18
Computer Science, Class XII, 2010-11 Chapter No.7 (Data File Handling)
1. What do you mean by ios::trunc, ios::nocreate, ios::noreplace and ios::binary file mode? 2. Distinguish between ios:: ate and ios :: app? 3. Differentiate between functions read() and write(). /* CBSE 1999 */ 4. Write name of two member functions belonging to fstream class./* CBSE 1998 */ 5. Distinguish between ios::out and ios::app. /* CBSE 2001*/ 6. Name two member functions of ofstream class. /* CBSE 2000*/ 7. Write a function in C++ to count the number of uppercase alphabets present in a text file ARTICLE.TXT. /* CBSE 2008 */ 8. Write a function in C++ to print the count of the word is as an independent word in a text file DIALOGUE.TXT. /* CBSE 2007 */ For example,if the content of the file DIALOGUE.TXT is This is his book. Is this book good? Then the output of the program should be 2. 9. Given a binary file GAME.DAT, containing records of the following structure type. struct Game /* CBSE 2007 */ { char GameName[20] ; char Participate[10][30] ; }; Write a function in C++ that would read contents from the file GAME.DAT and creates a file named BASKET.DAT copying only those records from GAME.DAT where the game name is Basket Ball. 10. Observe the program segment given below carefully,and answer the question that follows: class Labrecord /* CBSE 2007 */ { int Expno ; char Experiment[20] ; char Checked ; int Marks ; public : void EnterExp( ) ; //function to enter Experiment details viod ShowExp( ) ; //function to display Experiment details char RChecked( ) //function to return Expno {return Checked ;} void Assignmarks (int M) //function to assign Marks { Marks = M ; } }; void ModifyMarks( ) { fstream File ; File.open (Marks.Dat, ios :: binary || ios :: in || ios :: out) ; Labrecord L ; int Rec=0 ; while (File.read ( (char*) &L,sizeof (L) ) ) { if (L.RChecked( )= =N) L.Assignmarks (0) else L.Assignmarks (10) //Statement 1
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
19
statement1 and statement 2 using Seekg() and tellg() functions for performing the required task #include <fstream.h> class Car { char No_Plate[15],Car_type[20]; public : /* function to count the total no. of records in a file */ int Countrec(); }; int Car::Countrec() { fstream file ; file.open( Veh.dat,ios::binary| ios::in); _______________________________ //statememt1 int bytes = ________________________ //statement 2 int Count = bytes/sizeof(Car); Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919 21
Delhi from a binary file TRAIN.DAT, assuming the binary file is containing the objects of the following class. /* CBSE 2010 */ class TRAIN { int Tno; char From[20]; char To[20]; public: char* GetFrom( ){return From;} char* GetTo( ){return To;} void Input(){cin>>Tno;gets(From);gets(To);} void Show(){cout<<Tno<<From<<To<<endl;} }; 24. Write a function in C++ to add new object at the bottom of the binary file Train.Dat. Assuming that binary file is containing the objects of the following class: class Train { int Tno; char Tname[20]; char start_place[20]; public: void enter( ) { cin>>Tno ; gets(Tname) ; gets(start_place);} void display( ) { cout<<Tno << Tname << start_place; } char *ret_place( ) { return start_place; } };
22
23
/* CBSE 2004 */
/* CBSE 2007 */
24
25
13. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C. Assuming array A and B are sorted in ascending order and the resultant array C is also required to be in ascending order. 14. Write a function in C++ to merge the contents of two sorted arrays A & B into third array C. Assuming array A is sorted in ascending order, B is sorted in descending order, the resultant array is required to be in ascending order. 15. Write a function in C++ to combine the contents of two equi-sized arrays A and B by computing their corresponding elements with the formula 2*A[i]+3*B[i]; where value i varies from 0 to N-1 and transfer the resultant content in the third same sized array. 16. Write a function in C++ to find the sum of both left and right diagonal elements from a two dimensional array (matrix). 17. Write a function in C++ which accepts an integer array and its size as arguments/parameters and
exchanges the values of first half side elements with the second half side elements of the array.
Example: /*CBSE 2005*/ If an array of eight elements has initial content as 2,4,1,6,7,9,23,10 The function should rearrange the array as 7,9,23,10,2,4,1,6 18. Write a function in C++ which accepts a 2D array of integers and its size as arguments and displays the elements of middle row and the elements of middle column. /* CBSE 2007 */ [Assuming the 2D Array to be a square matrix with odd dimension i.e. 33, 55, 77 etc...] Example, if the array content is 354 769 218 Output through the function should be : Middle Row : 7 6 9 Middle Column : 5 6 1 19. 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 2 D array is given below The resultant 2 D array is given below /* CBSE 2006 */ If the array is 1, 2, 3 If the array is 1, 2, 3, 4, 5, 6 The resultant 2 D array is given The resultant 2 D array is given below below 1 0 0 0 0 0 1 0 0 1 2 0 0 0 0 1 2 0 1 2 3 0 0 0 1 2 3 Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919 26
20. Write a function in C++ to print the product of each row of a two dimensional integer array passed as the argument of the function. /* CBSE 2008 */ Example: if the two dimensional array contains 20 40 60 40 Then the output should appear as : Product of Row 1= 8000 Product of Row 2= 60000 Product of Row 3= 36000 Product of Row 4= 24000 21. Write a function in C++ to find sum of rows from a two dimensional array. 22. Write a function UpperHalf ( ) which takes a two dimensional array A, with size N rows and N columns as argument and point the upper half of the array. Eg: If A is 2 3 1 5 0 The output will be 2 3 1 5 0 7 1 5 3 1 1 5 3 1 2 5 7 8 1 7 8 1 0 1 5 0 1 0 1 3 4 9 1 5 5 23. Write a function LowerHalf ( ) which takes a two dimensional array A, with size N rows and N columns as argument and point the lowerr half of the array. Eg: If A is 2 3 1 5 0 The output will be 2 7 1 5 3 1 7 1 2 5 7 8 1 2 5 7 0 1 5 0 1 0 1 5 0 3 4 9 1 5 3 4 9 1 5 24. Write a user defined function in C++ which accepts a squared integer matrix with odd dimensions
(3*3, 5*5 ) & display the square of the elements which lie on both diagonals. For eg. :
40 50 30 20
10 30 20 30
2 5 7 3 7 2 5 6 9 The output should be: Diagonal one : 4, 49, 81 Diagonal two : 49, 49, 25
27
6. Explain Cartesian product of two relations. /* CBSE 2001 */ 7. What is a relation? What is the difference between a tuple and an attribute? /* CBSE 1998 */
28
iv. v. vi.
3. Consider the following tables ACTIVITY and COACH. Write SQL commands for the statements (i) to (vi) and give outputs for SQL queries (vii) to (xii) Table: ACTIVITY ACode ActivityName ParticipantsNum PrizeMoney ScheduleDate 1001 Relay 100x4 16 10000 23-Jan-2004 1002 High jump 10 12000 12-Dec-2003 1003 Shot Put 12 8000 14-Feb-2004 1005 Long Jump 12 9000 01-Jan-2004 1008 Discuss Throw 10 15000 19-Mar-2004 Table: COACH PCode Name ACode 1 Gulam Nabi 1001 2 Roma Khanna 1008 3 Amit Bohra 1001 4 Bhupendra 1003 (i) To display the name of all activities with their Acode in descending order. (ii) To display sum of PrizeMoney for each of the Number of participants groupings (as shown in column ParticipantsNum 10,12,16) (iii) To display the coachs name and ACode in ascending order of ACode from the table COACH. (iv) To display the content of the ACTIVITY table whose ScheduleDate earliar than 01-JAN-2004 in ascending order of ParticipantNum. (v) To display details of those activities which are having PrizeMoney more than 7000 (vi) To display the content of the ACTIVITY table in ascending order of ScheduleDate (vii). SELECT COUNT(DISTINCT ParticipantsNum) FROM ACTIVITY; (viii)SELECT MAX(ScheduleDate),MIN(ScheduleDate) FROM ACTIVITY; (ix) SELECT SUM(PrizeMoney) FROM ACTIVITY; (x) SELECT SUM(PrizeMoney) FROM ACTIVITY Group By ParticipantNum; (xi) SELECT DISTINCT ACode FROM COACH; (xii) SELECT AVG(PrizeMoney) FROM ACTIVITY; 4. Write SQL commands (a) to (m) and outputs (n) to (s) on the basis of Teacher relation given below: No Name Age Department DateofJoin Salary Sex 1 Jugal 34 Computer 10-JAN-97 12000 M 2 Sharmila 31 History 24-MAR-98 20000 F 3 Sandeep 32 Maths 12-DEC-96 30000 M 4 Sangeeta 35 History 01-JUL-99 40000 F
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
29
30
13. Write the equivalent expression for the following logical circuit: /* CBSE 2006 Comp. */
14. Write the equivalent expression for the following Logical Circuit:
/* CBSE 2006 */
31
16. Express P+Q R in canonical POS form. /* CBSE 2006 */ 17. Reduce the following Boolean expression using K-Map: /* CBSE 2006 Comp. */ F(P,Q,R,S)=?(l,3,5,8,11,12,15 ) 18. Reduce the following Boolean expression using K-Map: /* CBSE 2006 */ F(P, Q, R, S) = p (0,3,5,6,7, 11, 12, 15) 19. Express P+QR in canonical SOP form. /* CBSE 2006 */ 20. Reduce the following Boolean expression using K-Map. /* CBSE 2006 */ F(P, Q ,R, S) = ?(0,3,5,6,7,11,12,15) 21. Reduce the following Boolean expression using K-Map. /* CBSE 2010 */ F(A,B,C,D) = ?Y (3,4,5,6,7,13,15) 22. Reduce the following Boolean expression using K - Map: /* CBSE 2009 */ H(U,V,W,Z) = (0,1,4,5,6,7,11,12,13,14,15) 23. Draw a Logical Circuit Diagram for the following Boolean Expression: /* CBSE 2008 */ A . (B + C') 24. Convert the following Boolean expression, into its equivalent Canonical Product of Sum Form(POS) : A. B' .C + A'. B. C + A'. B. C' /* CBSE 2008 */ 25. Reduce the following Boolean expression using K - Map: /* CBSE 2008 */ F(A,B,C,D) = (0,1,2,4,5,8,9,10,11) 26. Obtain a simplified form for the following Boolean Expression using Karnaughs Map : F(a, b, c, d) = ? (0, 1, 2, 4, 5, 7, 8, 9, 10, 11, 14) ? /* CBSE 2004 */ 27. Reduce the following Boolean expression using K - Map: /* CBSE 2005 */ F (A, B, C, D) = p+ (0, 1, 2, 3, 4, 5, 10, 11, 15) ?+ 28. Write the equivalent Canonical Product of Sum Expression for the following Sum of Product Expression F(X, Y, Z) = ?} (0, 2, 4, 5) ?} /* CBSE 2007 */ 29. Reduce the following Boolean expression using K-Map: /* CBSE 2007 */ F(A, B, C, D) = p(5,6,7,8,9,12,13,14,15) 30. Convert the following Boolean expression into its equivalent Canonical Sum of Product Form(SOP): (X+Y+Z).(X+Y+Z).(X+Y+Z).(X+Y+Z). 31. Draw logical circuit diagram for the following Boolean expression. F= AB + BC + CA 32. Write the equivalent canonical POS expression for the following SOP expression: F(x,y,z)=S< (0,2,5,6). 33. Prove that XY+YZ+YZ=Y algebraically. 34. If F(w,x,y,z) = (1,3,5,7,,8,9,10,11,12,13,14,15) , obtain the simplified form using K-Map. 35. State Duality principle. Give the dual of the expression: ft+ty 36. Draw the circuit diagram for the following Boolean expression : (A+B)(A+B)(A+B) 37. Reduce the following Boolean expressions using K-Map: i) F(A,B,C,D)= ? (0,1,2,4,5,8,9,10,11) ii) F (A, B, C, D) =?(0,2,3,4,6,7,8,10,12) iii) F(A,B,C,D)= p_ (0,1,2,4,5,6,8,10)
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
32
(i) Mbps
(ii) KMph
(iii) MGps
33
Block B
Block D
34
Raj Building
Fazz Building
Harsh Building
Jazz Building
Center to center distances between various buildings is as follows: Harsh Building to Raj Building 50 m Raz Building to Fazz Building 60 m Fazz Building to Jazz Building 25 m Jazz Building to Harsh Building 170 m Harsh Building to Fazz Building 125 m Raj Building to Jazz Building 90 m
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
35
Number of Computers Wing A Wing S Wing J Wing H i. ii. iii. iv. 10 200 100 50
Suggest a suitable Topology for networking the computer of all wings. Name the wing where the Server is to be installed. Justify your answer. Suggest the placement of Hub/Switch in the network. Mention an economic technology to provide internet accessibility to all wings. The organization is planning to link its head office situated in Delhi with the offices at Srinagar. Suggest an economic way to connect it; the company is ready to compromise on the speed of connectivity. Justify your answer.
Mohd. Hashim, PGT (Computer Sc.), E-mail: hashim_mbd@yahoo.co.in, 9950589919
36
Finance Unit Media Unit 15 KM In continuation of the above, the company experts have planned to install the following number of computers in each of their office units: Production Unit 150 Finance Unit Media Unit i. 35 10
ii.
iii.
iv.
Corporate Unit 30 Suggest the kind of network required (out of LAN, MAN, WAN) for connecting each of the following office units: Production Unit and Media Unit Production Unit and Finance Unit Which one of the following devices will you suggest for connecting all the computers within each of their office units? Switch/Hub, Modem, Telephone Which of the following communication media, will you suggest to be procured by the company for connecting their local office units in Chennai for very effective (High Speed) communication? Telephone Cable, Optical Fiber, Ethernet Cable Suggest a cable/wiring layout for connecting the company's local office units located in Chennai. Also, suggest an effective method/technology for connecting the company's office unit located in Delhi.
37