kvgurgaon.files.wordpress.com file · web viewfunction draw_nos() to choose and display the details...

18
COMPUTER SCIENCE Class XII 1. (a) Differentiate between Actual and Formal Parameters in C++. Also give suitable examples of each in C++. (b) Name the header file(s) that shall be needed for successful compilation of the following: void main() { char *name=”P.O.I.N.T.E.R”; intlen=strlen(name); charename[20]; gets(ename); if (len= =strlen(ename)) len++; } 2. a) What is an inline function? Explain its uses with an example. b) Define a class STATIONARY inc++ with following specification Private members: Type of string type Manufacturer of string type Scode of int type Cost of float type Qty integer type Discount of float type Price of float type A member function FindDisc()to calculate Discount as per following rule: If item is Pencil and Qty<=50 discount is 0 Qty>50 discount is 5% If item is Pen and Qty<=50 discount is 0 Qty>50 and <=100 discount is 10% Qty>100 discount is 15% Public Members: A constructor to initialize cost, Price, Scode, Qty and Discount as 0 and type as “Pen”. A function Purchase () to allow uses to enter values for all data members except Discount and call FindDisc() function to calculate Discount and Price. A function ShowAll() to allow user to view the content of all data members c) Answer the following questions (i) to (iv) based on the following code: class medicine { char category [10]; chardate_of_manufature[10]; char company[20]; public:

Upload: trinhnguyet

Post on 06-Aug-2019

216 views

Category:

Documents


0 download

TRANSCRIPT

COMPUTER SCIENCE Class XII1. (a) Differentiate between Actual and Formal Parameters in C++. Also give suitable examples of each

in C++.(b) Name the header file(s) that shall be needed for successful compilation of the following:

void main(){ char *name=”P.O.I.N.T.E.R”;

intlen=strlen(name);charename[20];gets(ename);if (len= =strlen(ename))

len++;}

2. a) What is an inline function? Explain its uses with an example.b) Define a class STATIONARYinc++ with following specification

Private members: Type of string type Manufacturer of string type Scode of int type Cost of float type Qty integer type Discount of float type Price of float type A member function FindDisc()to calculate Discount as per following rule:

If item is Pencil andQty<=50 discount is 0Qty>50 discount is 5%

If item is Pen and Qty<=50 discount is 0Qty>50 and <=100 discount is 10%Qty>100 discount is 15%

Public Members: A constructor to initialize cost, Price, Scode, Qty and Discount as 0 and type as “Pen”. A function Purchase () to allow uses to enter values for all data members except Discount and call

FindDisc() function to calculate Discount and Price. A function ShowAll() to allow user to view the content of all data members

c) Answer the following questions (i) to (iv) based on the following code:class medicine{ char category [10];

chardate_of_manufature[10];char company[20];public:medicine();voidentermedicinedetails();voidshowmedicinedetails();

};class capsules: private medicine{protected:

charcapsule_name[30];charvolume_label[20];public:float price;capsules();voidentercapsuledetails();voidshowcapsuledetails();

};

class antibiotics: public capsules{ intdosage_units;

charside_effects[20];intuse_within_days;public:antibiotics();voidenterdetails();voidshowdetails();

};d) Define a class Housing with the following specification:

Private members: Name 20 CharactersType CharacterCost floatReg_no integer (range 10-1000)

Public members: Constructor to assign Name & Type as “NULL”, Cost &Reg_no as 0; ReadData() function to read an object of Housing type. DisplayData() function which prints the details of an object. Function Draw_nos() to choOse and display the details of two houses selected randomly from an

array of ten objects of type Housing. Use random function to generate the registration numbers to match with Reg_no from the array.

3. What is the difference between object oriented programming and procedural programming?

4. How does OOP overcome the shortcomings of traditional programming approaches?

5. Reusability of classes is one of the major properties of OOP. How is it implemented in C++?

6. How is matching done in case of overloaded functions?7. When should default arguments be preferred over function overloading and

vice-versa?8. Solve the April Test-2012. Prepare for July test-2012.9. Review Chapters 1-6.10.A test will be conducted on 1st week of July 2012.11.A separate notebook should be prepared for Summer Break Holiday Home work

and submit on 26th June 2012.

Teacher: AshuAneja