You are on page 1of 12

Class XII Computer Science(083) Practical Assignments

Cscience_1 : Write a Program in C++ to add two distance type objects into third one. Structure distance contains following components1. feet (integer type) 2. inches (integer type) (Program must have following general functions1. To input a distance type object. 2. To add two distance type objects (Pass two distance type arguments and return a distance type object). 3. To display distance type object.) Cscience_2 : Imagine a ticket selling booth at a fair. People passing by are requested to purchase a ticket. A ticket is priced Rs. 2.50/- The booth keeps the track of the number of people that have visited the booth, and of the total amount of money collected. Model this ticket selling booth with a class ticbooth including following members : Data Members : Number of people visited. Total amount of money collected. Member Functions : To assign initial values (assign 0 to both data members) To increment only people total in case ticket is not sold out. To increment people total as well as amount total if a ticket is sold out To display the two totals To display the number of tickets sold out ( a tricky one) Test above-mentioned class in main() function. Cscience_3 : Define a class to represent batsmen in a cricket team. Include the following members: Data members : First name Last name Runs made Number of fours

Class XII, Computer Science(083) ,Practical Assignments, Page :#1

Number of sixes Member Functions : To assign the initial values To update runs made (It should simultaneously update fours and sixes, if required) To display the batsmans information. Test this class in main() function. Make 11 objects to represent a team. Make a menu with following options. 1. Assign the basic values to all of the team members. 2. Update the information of any batsman on the basis of his first name 3. Display the information of any batsman on the basis of his first name 4. Quit Cscience_4 : Write a program in C++ with the help of following class student Data Members : Name of the student Marks in five subject (An array of float) Total marks obtained Percentage No. of pass students (static) No. of fail students ( static) No. of first divisions (static) No. of second divisions (static) No. of third division (static) Member Functions. 1. To input detail of a student (Name and marks in five subjects) 2. To display detail of a student 3. To calculate the total marks, percentage and static member data. Declare this member function as private and call it from input detail function. 4. To display static data members detail (A static member function) . Test this class for 10 students. (An array of student type) (Note: If marks scored by student in every subject is>=33 , student is pass and division must be calculated as follows Percentage Division >=60 I

Class XII, Computer Science(083) ,Practical Assignments, Page :#2

>=50 and <60 II >=33 and <50 III Otherwise student is fail and division is supposed to be NIL.) Cscience_5 : Write a menu-driven program in C++ to calculate the volume of following shapes1. Volume of a cube 2. Volume of a box 3. Volume of a sphere. 4. Quit Make this program with the help of a class shape with followingMember data: p1 (type float) p2 (type float) p3 (type float) volume (type float) Member Functions : To input data members (Input as many as required) To calculate volume of various shapes (must be overloaded) To display the volume. Cscience_6 : Imagine a publishing company that markets both books and audio cassette versions of its works. Create a class Publication that stores the title (a string) and price (type float) of a publication. From this class derive two classes : book, which adds a page count (type int); and tape, which adds a playing time in minutes (type float). Each of these three classes should have a getdata() function to get its data from the user at the keyboard, and a putdata() function to display its data. Write a main() program to test the book and tape classes by creating instances of them asking the user to fill in their data with getdata(), and then displaying the data with putdata(). Test classes book and tape from main function. Implement the concept of member function over-riding.

Class XII, Computer Science(083) ,Practical Assignments, Page :#3

Cscience_7 : Write a menu-driven program in C++ with following options1. Creation of a text file (file must be created, character by character until a particular character is typed , like as you type # the file creation task gets stopped) 2. Reading of a created text file. (To display the contents of a text file) 3. Quit. Cscience_8 : Write a menu-driven program in C++ with following options1. Creation of a text file (say file is mixed.txt, it contains alphabets, digits or special characters) 2. Make separate files (This option creates three files- alpha.txt (contains alphabets only), digit.txt (contains digits only) and special.txt (contains special characters only) taking data from mixed.txt) 3. Display a file (This option displays the contents of a particular file out of above-mentioned four files, by asking its name, if not found reports file not found) 4. Quit Cscience_9 : Write a menu-driven program in C++ with following options1. To add records (Name, Rollno, Marks ) of students (Add records till the user wants yes) 2. Display all the records 3. Display a particular record on the basis of Roll No. 4. Quit Cscience_10 : Write a program in C++ with the help of following class employee Member Data : Employee name Employee code Basic Salary Da Hra Total salary Member Functions: 1. To input employee detail (name, code and basic) 2. To calculate following

Class XII, Computer Science(083) ,Practical Assignments, Page :#4

Code 1 2 Any other

Da 50% of basic 40% of basic 30% of basic

Hra 30% of basic 25% of basic 20% of basic

Total Salary=Basic + Da + Hra This function must be a private function and must be called from input detail function 3. A function which returns the address of that object which has got higher basic salary (This function compares calling object and passing object) 4. To display the detail of the student In main() function make 10 objects of employee. Input and calculate detail of every employee . Finally display the detail of that employee who draws the highest salary. Cscience_11: Write a program in C++ with the help of class array_search with following membersMember data : An array ar of integer with 100 elements No .of elements actually used by user (int n) Member Functions1. To input n, and n number of elements 2. Linear serch 3. Binary search (If array is in ascending order) 4. To display n elements of the array Make a menu in C++ with following options1. Array Input 2. Linear Search 3. Binary Search 4. Array display 6. Quit Cscience_12: Write a program in C++ with the help of class array_update with following membersMember data : An array ar of integer with 100 elements No .of elements actually used by user (int n)

Class XII, Computer Science(083) ,Practical Assignments, Page :#5

Member Functions1. To input n, and n number of elements 2. To insert an item in the array if array is in ascending order 4. To delete an item from the array 5. To display n elements of the array Make a menu in C++ with following options1. Array Input 2. Insertion 3. Deletion 4. Array display 6. Quit Cscience_13: Write a program in C++ with the help of class array_sort with following membersMember data : An array ar of integer with 100 elements No .of elements actually used by user (int n) Member Functions1. To input n, and n number of elements 2. Selection sort 3. Bubble sort 4. Insertion sort 5. To display n elements of the array Make a menu in C++ with following options1. Array Input 2. Selection sort 3. Bubble sort 4. Insertion sort 5. Array display 6. Quit Cscience_14: Write a program in C++ with the help of class array_merge with following membersMember data : An array a of integer with 100 elements No .of elements actually used by user in array a (int l) An array b of integer with 100 elements No .of elements actually used by user in array b (int m)

Class XII, Computer Science(083) ,Practical Assignments, Page :#6

An array c of integer with 200 elements No .of elements actually used by user in array c (int n) Member Functions1. To input array a and b with size l, m respectively 2. merge1(), it merges array a and b to form c, if a and b are sorted in ascending and descending order respectively 3. merge2(), it merges array a and b to form c, if a and b are sorted in descending and ascending order respectively 4. merge3(), it merges array a and b to form c, if a and b are sorted in ascending order 5. merge4(), it merges array a and b to form c, if a and b are sorted in descending order

(Note :Array c is required in ascending order.)


6. display(), To display all the arrays a, b and c. Make a menu in C++ with following options1. To input array a, b 2. To merge array a and b to form c, if a and b are sorted in ascending and descending order respectively 3. To merge array a and b to form c, if a and b are sorted in descending and ascending order respectively 4. To merge array a and b to form c, if a and b are sorted in ascending order 5. To merge array a and b to form c, if a and b are sorted in descending order 6. To display all the arrays. 7. Quit Cscience_15: Write a program in C++ with the help of class linked_list with following members(Nodes of the linked list are created by self-referential structure nodestruct node { int info; node *next; }; )

Class XII, Computer Science(083) ,Practical Assignments, Page :#7

Member data : A pointer start which keeps the address of first node. Member Functions1. A constructor which keeps NULL in start. 2. To add a node in a linked list 3. For traversal (Display info. of each node) 4. To search a particular node, on the basis of information of nodes given. Make a menu in C++ with following options1. To create a linked list. 2. For linked list traversal. 3. To search a particular node 4. Quit. Cscience_16: Write a program in C++ with the help of class array_stack with following membersMember data : An array of integer ar[MAX] (Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user) top (It keeps the index of top most array element) Member Functions1. A constructor that initialize 1 in top (Makes array_stack ready to push) 2. To push an item in stack. 3. To pop an item from stack 4. To display the content of stack without popping Make a menu in C++ with following options1. A initialize the stack( top must be -1) 2. To push an item in stack. 3. To pop an item from stack 4. To display the content of stack without popping 5. Quit

Cscience_17: Write a program in C++ with the help of class linked_stack with following members-

Class XII, Computer Science(083) ,Practical Assignments, Page :#8

(Nodes of the linked stack are created by self-referential structure nodestruct node { int info; node *next; }; ) Member data : A pointer top which keeps the address of top-most node. Member Functions1.A constructor that initialize NULL in top (Makes array_stack ready to push) 2. To push an item on stack. 3. To pop an item from stack 4. To display the content of stack without popping Make a menu in C++ with following options1. A initialize the stack( top must be NULL) 2. To push an item in stack. 3. To pop an item from stack 4. To display the content of stack without popping 5. Quit Cscience_18: Write a program in C++ with the help of class array_queue with following membersMember data : An array of integer ar[MAX] (Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user) front and rear ( They keep the index of front-most and rear-most array element) Member Functions1. A constructor that initialize 1 in front and rear (Makes array_queue ready for insertion) 2. To insert an item in queue. 3. To delete an item from queue 4. To display the content of queue without deletion.

Class XII, Computer Science(083) ,Practical Assignments, Page :#9

Make a menu in C++ with following options1. To initialize the queue( front and rear must be -1) 2. To insert an item in queue 3. To delete an item from queue 4. To display the contents of queue without deletion 5. Quit Cscience_19: Write a program in C++ with the help of class linked_queue with following members(Nodes of the linked queue are created by self-referential structure nodestruct node { int info; node *next; }; ) member Data : front and rear ( They keep the memory address of front-most and rear-most linked queue) Member Functions1. A constructor that initialize NULL in front and rear (Makes linked__queue ready for insertion) 2. To insert an item in queue. 3. To delete an item from queue 4. To display the content of queue without deletion. Make a menu in C++ with following options1. To initialize the queue( front and rear must be NULL) 2. To insert an item in queue 3. To delete an item from queue 4. To display the contents of queue without deletion 5. Quit Cscience_20: Write a program in C++ with the help of class circular_array_queue with following membersMember data : An array of integer ar[MAX]

Class XII, Computer Science(083) ,Practical Assignments, Page :#10

(Where MAX is a globally-declared symbolic-constant (integer) with size according to the requirement of user) front and rear ( They keep the index of front-most and rear-most array element) Member Functions1. A constructor that initialize 1 in front and rear (Makes circular_array_queue ready for insertion) 2. To insert an item in circular queue. 3. To delete an item from circular queue 4. To display the content of circular queue without deletion. Make a menu in C++ with following options1. To initialize the queue( front and rear must be -1) 2. To insert an item in queue 3. To delete an item from queue 4. To display the contents of queue without deletion 5. Quit Cscience_21: On the basis of following table supplier. Table : SUPPLIER Name City Itemno SuppliedQty Rate Puneet Delhi 1008 100 40 Pradeep Bangalore 1009 200 30 Tanmay Delhi 1008 150 40 Rohini Bombay 1005 190 20 Tanya Bombay 1003 20 50 Aditi Madras 1008 180 40 Kush Delhi 1009 300 30 Write SQL commands for (b) to (g) and write the outputs of SQL commands given in (h) with the help of above shown table. (b) Display names of suppliers whose names start with the letter T. (c) Display details of suppliers residing in Delhi. (d) Display supplier name, item numbers, and supplied quantity for quantity > 150. (e) Create a view with one of the columns as rate * 10. (f) List the suppliers name in the descending order of supplied quantity. Numbers S001 S002 S003 S004 S005 S006 S007

Class XII, Computer Science(083) ,Practical Assignments, Page :#11

(g) List the different cities contained in supplier table. (h) Give the output of the following SQL commands on the basis of table supplier. (i) (ii) (iii) SELECT MIN(Rate) FROM SUPPLIER SELECT COUNT(DISTINCT City) FROM SUPPLIER SELECT Name, Itemno FROM SUPPLIER SuppliedQty>150 (iv) SELECT (Rate*SuppliedQty) FROM SUPPLIER SuppliedQty>200

WHERE WHERE

NOTE : Similarly four more assignments Cscience_22, Cscience_23, Cscience_24, and Cscience_25 can be taken up by students on their own for SQL.

Class XII, Computer Science(083) ,Practical Assignments, Page :#12

You might also like