Sie sind auf Seite 1von 11

1

RYAN INTERNATIONAL SCHOOL


MAYUR VIHAR
LIST OF PROGRAMS FOR BOARD PRACTICALS
SESSION 2013-2014
STD : XII SCIENCE
SUBJECT : COMPUTER SCIENCE
MADE BY : MS. NUPUR GUPTA
H.O.D. COMP.SC.! MAYUR VIHAR"
ARRAYS USING FUNCTIONS"
Q1. Write a program to 1.add two matrices 2. Subtract 2 matrices 3. Multiply 2 matrices. Use switch
case and use functions to achieve the tas.
Q2. Write a program to 1.transpose a matri! 2. "ind the row sum and column sum of a given matri!.
Use switch case and use functions to achieve the tas.
Q3. Write a program to sum the elements above and below the main diagonal of a matri!. #efine
different functions to do the same.
Q$. Write a program to illustrate the two types of searches in an integer type array. Mae use of
functions and mae a menu driven program.
Q%. Write a program to illustrate insertion &with position' in an array &the position can be the beginning
or the end or in middle anywhere at a specified place' &all three cases are to be handled'.Write
functions for all three separately. (nd mae the program menu driven and user friendly.
Q). Write a program to illustrate deletion &with position' in an array &the position can be the beginning
or the end or in middle anywhere at a specified place* so all the cases should be handled'. Write
functions for all three separately. (nd mae the program menu driven and user friendly.
Q+. Write a program to illustrate all the three sorts , -nsertion* Selection and .ubble sort in an array.
Mae use of functions to do the same. Mae a menu driven and user friendly program.
Q/. Write a program to merge two given arrays into the third array 0 .Use switch case and implement
the same with atleast $ different combinations. Mae use of functions.
Q1. (n array* (22(3 4256* consists of 25 positive integers .Write a complete user friendly* menu
driven functions oriented 077 program to do the following8
1. "ind the pairs of integers stored in ( having sum 9 %5
2. "ind the number of elements which are odd
3. "ind the number of elements which are even
$. "ind the number of elements which are divisible by 35
%. "ind the largest of all the elements
). "ind the smallest of all the elements
+. "ind the average of all the elements
Q15. :et ( be ; < ; two=dimensional array. Write user=defined functions in 077 for the following8
1. >o find the number of non=?ero elements in (.
2. >o find the sum of all elements in (.
3. >o find the sum of all elements (4i64@6 for which i A @.
$. >o find the sum of all elements (4i64@6 for which i B @.
%. >o find the product of all elements (4i64@6 for which i 9 @.
2
STRUCTURES
Q1. Write a program to define a structure CD;DU2 with the following data members8
1. ;ame of the Winners 2.>ype of the (ward 3.Eri?e (mount
;ow declare an array of structure with ; number of elements and perform the following using
separate functions for each8
1. "ill the array
2. Show the contents of the array in a tabular form
3. #isplay all those winners who have earned a pri?e amount more than %5*555
$. #isplay the name and the pri?e amount of the biggest pri?e amount winner
Q2. #eclare a structure F:F0>2-0 having the following members8
0ustG;D* ;ame* ;oGofGunitsconsumed and bill.
>hen the bill has to be calculated as below8
Units consumed >ariff
"or the first 155 units 2s. 5.$5 per unit
"or the ne!t 255 units 2s. 5.%5 per unit
"or the ne!t 355 units 2s. 5.+% per unit
"or the ne!t $55 units 2s. 1.55 per unit
.eyond 1555 units 2s. 1.%5 per unit
Write a complete 077 program to calculate the bill and display the information of all the customers in
the sorted order of customer number.
Mae use of functions and mae the program interactive and menu driven.
CLASSES AND OBJECTS
Q1. #eclare a class to represent ban account of 15 customers with the following data members. ;ame
of the depositor* (ccount number* >ype of account* &S for Saving and 0 for 0urrent'* .alance
amount. >he class also contains member functions to do the following8
&i' >o initiali?e data members &ii' >o deposit money
&iii' >o withdraw money after checing &iv' to display the data Members.
>he balance &minimum balance in 2s. 1555'
Q 2.Write a 077 program using classes and ob@ects to simulate result preparation system for 25
students. >he data available for each student includes rollno* name and mars in 3 sub@ects. >he
percentage mars are the average mars and the grade is calculated as follows8
Eercentage mars grade
B%5 HFI
A9%5B)5 H#I
A9)5B+% H0I
A9+%B15 H.I
A915B155 H(I
Q 3. #efine a class >ravel in 077 with the following specifications8
Members8
>ravelcode *Elace * ;oGofGtraveler * ;oGofG.uses
"unctions8
1. ( constructor function to assign initial values of >ravelcode as 251 *place as J;ainital J *
;oGofGtraveler as 15 * ;oGofG.uses as 1
3
2. ;ew>ravel & ' to let the user enter data , >ravel code*Elace and noGofGtravelers.(lso *
assign ;oGofGbuses as per the following conditions8
;oGofGtravelers ;oGofGbuses
B25 1
9A25 and B$5 2
9A$5 3
3. Showtravel & ' to display all the data
$.( destructor function to release memory.
Q $. Write a 077 program to perform the various operations on a string class without using language
supported built=in string functions. >he operations to be done on the class are8
&a' 2ead a string
&b' #isplay the string
&c' 2everse the string
&d' 0opy the string into an empty string
&e' 0oncatenate two strings
Q %. Write a class to represent a vector &1 , dimensional numeric array' . -nclude the following
member functions 8
1. "or vector creation
2. "or modification of a given element
3. "or displaying the largest value in the vector
$. "or displaying the smallest value in the vector
%. "or displaying the entire vector
DATA FILE HANDLING
Q1.Write a complete menu driven program that creates a file *calculates and displays the total number
of vowels in the file *calculates and displays the total number of spaces in the file * calculates and
displays the total number of alphabets in the file * calculates and displays the total number of
words in the file. Mae use of the following functions and as the user for hisKher choice 8
1. createfile& ' 2. displayfile& ' 3. vowelchec& '
$. spacecount& ' %. alphacount & ' ). wordscount& '
Q 2.Liven a .inary file phone.dat * containing records of the following type8
class Ehonelist
M
char ;ame4256N
char (ddress4356N
char (reacode4%6N
char Ehone;um41%6N
public8
void 2egister& 'N
void Show& 'N
void >ransfer& 'N
int 0hec0ode&char (046'
M
return strcmp&(reacode* (0'N
O
ON
$
Write complete menu driven program * complete the definitions of the functions.Poid 2egister& '
function to input all data and write the records to the file * void Show& ' to display all data after
reading from the file .Poid >ransfer& ' to copy those records which are having (reacode as J#F:Q
from Ehone.dat to EhoneGnew.dat .
Q 3. Liven a .inary file (EE:3.#(> * containing records of the following class (pplicant type8
0lass (pplicant
M
0har (G2no4156N
0har (G;ame4356N
-nt (GscoreN
Eublic8
Poid Fnrol & '
M
Lets&(G2no'N
Lets&(G;ame'N
0inAA(GScoreN
O
Poid Status& '
M coutBBsetw&12'BB(G2noN
0outBBsetw&32'BB(G;ameN
0outBBsetw&3'BB(GScoreBBendlN
O
-nt 2eturnScore& '
M return (GScoreN
ON
Write functions in c77
1.to write the ob@ects of the file on to dis
2. >o read ob@ects from the file and display on screen
3. to read and display the details od those students whose (GScore is A +5.
#evelop into a complete menu driven 077 program
Q$. (ssuming the class (pplicant given below* write functions in 077 to perform the following8
class (pplicant
M char (G2no4156N
char (G;ame4256N
int (GScoreN ON
&i' Write the ob@ects of class to a binary file.
&ii' 2eads the ob@ects of class from binary file and display them on screen.
&iii' Searches for a particular (G2no.
&iv' 2eads the file and lets the user mae changes in data and invoes the function to display the
values.
&v' Rust displays contents of the file.
;ote 8 -nclude all the reSuired functionIs prototypes in the public section of the class.
Q %. (ssuming the class S>U#F;> given below* write functions in 077 that perform the following8 =
class S>U#F;>
M char SG(dmno4156N
char SG;ame4356N
%
int percentageN
public8
void Fnterdata& '
M gets&SG(dmno'N
gets&SG;ame'N
cinAApercentageN O
void #isplaydata& '
M coutBBsetw&12'BBSG(dmnoBBendlN
coutBBsetw&32'BBSG;ameBBendlN
coutBBsetw&3'BBpercentageBBendlN O
int 2eturnEerccentage& '
M return percentageN O ON
&i' Write the ob@ects of the class to a binary file.
&ii' 2eads the ob@ects of the class from binary file and display them on screen.
&iii' Searches for a particular SG(dmno. Eermits modification
&iv' 2eads the file and lets the user mae changes in data and invoes #isplaydata & '
&v' (llows to delete a particular record as desired.
Q ) . Write a menu driven program to read* display* append* and delete records in the file
MDP-F.#(> .Use the class given below.
class Movie
M int movieGidN
char movieGname4256N
int noGofGseatsN
int ticetcodeN
int hallnoN
public8
void readdata& 'N
void display& 'N
void append& 'N
void delete& 'N
ON
Q +. Write a program that reads characters from the eyboard one by one. (ll lower case characters get
stored inside the file :DWF2* all upper case characters get stored inside the file UEEF2 and all other
characters get stored inside file D>CF2S.
LIN#ED LISTS! STAC#S $ %UEUES
Q1. Write a program in 077 that creates a complete lined list class.
Q2. Write a program to implement the use of Queue class.
Q3. Write a program to implement the use of Stac class.
Q$. Write a program in 077 to add* delete* search and display an element in a lined Sueue.
Q%. Write a complete menu driven program in 077 for the implementation of lined stac.
)
Q). Write a program to create a lined list and insert elements according to userIs choice at a given
position.
Q+. Write a program in 077 that creates a lined list. >hen displays the original list. ;ow the lined
list is to be reversed. >hen displays the reversed list. (nother function should split the list as per userIs
choice and then displays the splitted list. (ll this wor should be done using functions and should be as
per userIs choice in a menu driven program.
Q /. #esign a Sueue of % nodes based on the following structure8
struct
M char name4256N
char phoneno4156N
O >elediaryN
and perform the following operations on it8
(. to add a new node. .. to delete a node 0. to locate a node #. to display the Sueue after each
operation.
Q1. Write an interactive menu driven 077 program to implement circular Sueue using an array
consisting of integer data values.
Q15.0omplete the class with all function definitions. #evelop a complete menu driven program to
implement the array stac.
class stac
M
int data4156N
int topN
public8
stac& '
M top 9=1NO
void push& 'N
void pop& 'N
void delete &int -tem'N
ON
Q11 .0omplete the class with all function definitions. Use another Sueue to transfer data temporarily.
#evelop a complete menu driven program to implement the array Sueue.
class Queue
M
int data4156N
int front* rearN
public8
Queue& '
M front 9 rear 9 9=1NO
void insert& 'N
void remove & 'N
void delete &int -tem'N
ON
+
CONSTRUCTORS AND DESTRUCTORS
Q 1. #efine a class >ravelElan in 077 with the following descriptions8
Erivate members 8
Elan0ode Df type long
Elace Df type character array &string'
;umberGofGtravellers Df type integer
;umberGofGbuses Df type integer

Eublic members 8
( constructor to assign initial values of Elan0ode as 1551* Elace as J(graQ*
;umberGofGtravellers as %* ;umberGofGbuses as 1
( function ;ewElan& ' which allows user to enter Elan0ode* Elace and ;umberGofGtravellers.
(lso* assign the value of ;umberGofGbuses as per the following conditions 8
N&'()*+,-+.*/0)11)*2 N&'()*+,-+(&2)2
:ess than 25 1
FSual to or more than 25 and less than $5 2
FSual to $5 or more than $5 3
Q 2. #efine a class Dutfit in 077 with the following descriptions 8
Erivate members 8
D0ode Df type string
D>ype Df type string
DSi?e Df type integer
D"abric Df type string
DErice Df type float
( function -nitErice& ' which calculates and assigns the values of DErice as follows 8
"or the value of D"abric J#F;-MQ*
OT34) OP*56)R2"
>2DUSF2 1%55
R(0TF> 2%55
"or fabric other than J#F;-MQ the above mentioned DErice gets reduced by 2%U.
Eublic members8
( constructor to assign initial values of D0ode* D>ype and D"abric with the word J;D>
-;->-(:-SF#Q and DSi?e and DErice with 5.
( function -nput& ' to input the values of the data members D0ode* D>ype* DSi?e and D"abric
and invoe the -nitErice& ' function.
( function #isplay& ' which displays the content of all the data members for an Dutfit.
/
FUNCTION OVERLOADING
Q 1.Write a program to illustrate woring of function overloading. 0alculate interest amount using
function overloading.
Q 2.Write a 077 program that uses an area& ' function for the calculation of area of a triangle or a
rectangle or a sSuare. ;umber of sides &3 for triangle* 2 for rectangle* 1 for sSuare' suggest about the
shape for which area is to be calculated.
INHERITANCE
Q 1.Write a 077 program to read and display information about employees and managers. Fmployee
is a class that contains employee number* name* address and department. Manager class contains all
information of the employee class and a list of employees woring under a manager.
POINTERS
Q 1.Live the following incomplete class definition 8
0lass Elayer M char firstname41%6* surname41%6N
int runs* si!es* foursN
float strieGrateN
public8
Elayer& 'N
VElayer& 'N
char Wgetname& 'N
M return strcat&firstname*lastname'N O
int getruns& '
M return runsN O
int getsi!& '
M return si!esN O
int getfours& '
M return foursN O
float getstGrate& '
M return strieGrateN O
ON
Write a program that uses array of pointers to ob@ects to store the details of various Elayers. Let details
of the players from the user at the eyboard and print the details of the Elayer who has made ma!imum
runs.
S%L
Q1. Write SQ: commands for &a' to &f' on the basis of teacher relation given below8
2elation teacher
;o. ;ame. (ge #ept. #ate of
@oin
Salary Se!
1. Rugal 3$ 0omputer 15K51K1+ 12555 M
2. Sharmila 31 Cistory 2$K53K1/ 25555 "
3. Sandeep 32 Math 12K12K1) 35555 M
$. Sangeeta 3% Cistory 51K5+K11 $5555 "
%. 2aesh $2 Math 5%K51K1+ 2%555 M
). Shyam %5 Cistory 2+K5)K1/ 35555 M
+. Shiv om $$ 0omputer 2%K52K1+ 21555 M
/. Shalaha 33 MathIs 31K5+K1+ 25555 "
1
&a' >o show all information about the teachers of the history dept.
&b' >o list the names of the female teachers who are in the Cindi #ept.
&c' >o list all the teachers with their #ate of @oining in ascending order.
&d' >o display studentIs ;ame* "ee* (ge for Male teachers only.
&e' >o count the number of teachers with (geB23.
&f' >D insert a new row in the >F(0CF2 table .
Q2 0onsider the following tables WD2TF2S and #FS-L .Write the SQ: commands for the
statements &i' to &v'
WD2TF2S
W=-# "-2S> ;(MF :(S> ;(MF (##2FSS 0->3
152 Sam >ones 33 Flm St. Earis
15% Sarah (cerman $$5 U.S. 115 ;ew 3or
1$$ Manila Sengupta 2$ "riends
Street
;ew #elhi
215 Leorge Smith /3 "irst Street Coward
2%% Mary Rones /$2 Pine (ve. :osantiville
355 2obert Samuel 1 "ifth cross Washington
33% Cenry Williams 12 Moore
Street
.oston
$53 2onny :ee 121Carrison
Street
;ew 3or
$%1 Eat >hompson 11 2ed road Earis
#FS-L
WG-# S(:(23 .F;F"->S #FS-L;(>-D;
152 +%555 1%555 Manager
15% /%555 2%555 #irector
1$$ +5555 1%555 Manager
215 +%555 12%55 Manager
2%% %5555 12555 0ler
355 $%555 15555 0ler
33% $5555 15555 0ler
$53 32555 +%55 Salesman
$%1 2/555 +%55 Salesman
&i' >o display WG-# first name* (ddress and 0ity Df all the employees living in ;ew 3or
from the table worers.
&ii' >o display the contents of WD2TF2S table in ascending order of :(S>;(MF.
&iii' >o display the "irst name* last name and total salary of all clers from the tables
WD2TF2S and #FS-L *where >otal Salary is calculated as salary 7 benefits.
&iv' >o display the minimum salary among mangers and clers from the table #FS-L
&v' >o display firstname* lastname and their designation who have their salaries above )5555.
15
Q3.0onsider the following table 0D;S-L;D2 and 0D;S-L;FF. Write SQ: commands for
following statements.
TABLE : CONSIGNOR
C7,*ID C7,*N/') C7,*A88*)22 C5.3
;#51 2 Singhal Ear avenue ;ew #elhi
;#52 (mit Tumar 123* Ealm (venue ;ew #elhi
MU1% 2 Tohli %K( South Ear Mumbai
MU%5 S Taur 2+=T* westend Mumbai
TABLE : CONSIGNEE
C7))ID C7*ID C7))*N/') C7))A88*)22 65.3
MU5% ;#51 2ahul Tishore (.0 enclave Mumbai
;#5/ ;#52 E #hingra 1)KR* Moore enclave ;ew #elhi
TD51 MU1% ( E 2oy 2(* 0entral (venue Tolata
MU32 ;#52 S Mittal E 2$%* (. 0olony Mumbai
;#$/ MU%5 . E Rain 13* .loc #* ( Pihar ;ew delhi
1. >o display names of all 0D;S-L;D2 from MUM.(-.
2. >o display the 0nee;ame* 0nor;ame where consignor city is same as consignee
city.
3. >o display consignee detalils in ascending order of 0nee;ame.
$. >o display distinct city from consignor.
%. >o display 0neer;ame and 0nor;ame Where city is Mumbai.
11
Q $ study the following tables ":-LC>S and "(2FS and write the SQ: commands for the Suestions
that follow
F159:.2
":G;D. S>(2>-;L F;#-;L ;DG":-LC>S ;DGS>DES
-0351 MUM.(- #F:C- / 5
-0+11 .(;L:D2F #F:C- 2 1
M0151 -;#D2F MUM.(- 3 5
-0352 #F:C- MUM.(- / 5
(M/12 T(;EU2 .(;L(:D2F 3 1
-0/11 MUM.(- TD0C- 1 $
(M%51 #F:C- >2-P(;#2UM 1 %
MU$11 MUM.(- M(#2(S 3 3
-0+51 #F:C- (CFM#(.(# $ 5
"(2FS
":G;D (-2:-;FS "(2F >(<
-0+51 -;#-(; (-2:-;FS )%55 15
MU$11 S(C(2( 1$55 %
(M%51 RF> (-2W(3S 13$%5 /
-0/11 -;#-(; (-2:-;FS /355 $
-0352 -;#-(; (-2:-;FS $355 15
-0+11 -;#-(; (-2:-;FS 15%55 15
M0151 #F00(; (-2:-;FS 3%55 $
Q1 #isplay ":G;D and ;DG":-LC>S from JT(;EU2Q to J.(;L(:D2FQ .
Q2 #isplay the total fare collected by -;#-(; (-2:-;FS
Q3 display the ":G;D and "(2F to be paid for the flights from #F:C- to MUM.(-
Q$ #isplay S>(2>-;L* F;#-;L* (-2:-;FS and "(2F from ":-LC>S and "(2FS where >(<
greater than %
Q% display ":G;D and #-S>-;0> (-2:-;FS from ":-LC>S and "(2FS
WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

Das könnte Ihnen auch gefallen