Index For C++ Programming: Computer Science (083) Practical File For Class XII
Index For C++ Programming: Computer Science (083) Practical File For Class XII
Index For C++ Programming: Computer Science (083) Practical File For Class XII
#1/6
13. Define a POINT class for two-dimensional points (x, y). Include a default
constructor, a copy constructor, a negate() function to transform the point
into its negative, a norm() function to return the point's distance from the
origin (0,0), and a print() function besides the functions to input and display
the coordinates of the point.
Use this class in a menu driven program to perform various operations on a
point.
14. Write a program using the above class to define an array of 10 points and
input the data in the array. Then for each point tell if it lies on any axis (x
or y).
15. Create a class student with data members name, class, section, roll No. and
function members getdata(), printdata(), and promote(). From this class
derive a class 'Sr_std' with additional data member stream. Also include
another function member change_stream().
Use these classes in a program.
16. Write a program to input the name of a text file from the user and display:
a) The number of blanks present in the file.
b) The number of lines present in the file.
c) The number of capital alphabets present in the file.
d) The number of small alphabets present in the file.
e) The number of lines starting with a capital alphabet.
f) The number of words present in the file.
g) The number of digits present in the file.
h) The number of words ending with a vowel
17. Write a program to input the name of a text file from the user. Then input a
string and search for the string in the file. The program should an
appropriate message if the file with the given name is not present.
18. Write a program to input a text file name, read the contents of the file and
create a new file named COPY.TXT, which shall contain only those words
from the original file which don’t start with an uppercase vowel (i.e., with
‘A’, ‘E’, ‘I’, ‘O’, ‘U’). For example, if the original file contains
The First Step To Getting The Things You Want Out Of
Life is This: Decide What You Want. - Ben Stein
Then the text file COPY.TXT shall contain
The First Step To Getting The Things You Want Life is
This: Decide What You Want. - Ben Stein
19. Write an interactive C++ program to open a text file and then display the
following:
1) Frequency table of all the alphabetic characters present in the file.
2) Number of numeric characters present in the file.
20. Create a text file (w/o using any C++ program) containing the names of
students and their marks in the following format:
Ajay 350
Vijay 340
where name and marks are separated by either a space or a tab and end of
line is a record separator. Write a program to read this file and display the
records in two columns name and marks.
Within the name column, the students' names are to be left justified and
marks are to be right justified in the marks column.
#2/6
21. Declare a structure telerec in C++, containing name (20 characters) and
telephone number. Write a program to maintain a file of telephone records.
The program should allow the following functions on the file:
1) To append records in the file.
2) Display the name for a given telephone number. If the telephone
number does not exist then display error message "record not found".
3) Display the telephone number(s) for a given name. If the name does not
exist then display error message "record not found".
22. A blood bank maintains a data file that contains the following information
for every donor: Name, Date of Birth, Telephone number, Blood group.
Write a program in C++ to do the following:
1) Given a blood group, display name, date of birth and phone number of
all the persons of the given blood group.
2) Append records in the file.
3) Input a telephone number and modify the corresponding record.
23. Create two payroll files COMP1.DAT and COMP2.DAT. Each of the files
should have the following fields:
EmpNo : Integer
Name : A string of 20 characters
Salary : A floating point number.
Both the files should be created in the increasing order of the EmpNo. Your
program should then merge the two files and obtain a third file
NEWCOMP.DAT. The program should also display the data from all the three
files.
Do not use arrays for merging and sorting of the files. You can assume that
the EmpNo are unique.
24. Write a menu driven program in C++ to perform the following functions on a
binary file “BOOK.DAT” containing objects of the following class:
class Book
{ int BookNo;
char Book_name[20];
public:
// function to enter book details
void enterdetails();
//function to display Book details
void showdetails();
//function to return Book_no
int Rbook_no() {return Book_no;}
//function to return Book_name
int Rbook_name() {return Book_name;}
};
1. Append Records
2. Modify a record for a given book no.
3. Delete a record with a given book no.
4. Search for a record with a given Book name
5. Display a sorted list of records (sort on Book No.)
6. Display a sorted list of records (Sort on Book Name)
25. Write a program that reads a list of numbers from the user and places them
in an array of type float. Once the numbers are stored in the array, the
program should find their average and print it along with the list of
numbers. Use pointer notation wherever possible.
26. Write a program to create a linked list in which each node contains the
roll number and marks for a student of a class. Then display a list of all
those students whose marks are above 50.
#3/6
27.
Write a p€rogram to do the following:
Declare an integer variable and initialize it to any negative value (say -56).
Declare five pointer variables: pointer to int, pointer to char, pointer to
float, pointer to long, and pointer to unsigned int. Store the address of the
integer variable in the pointer to int. Then store this pointer’s value in each
of the other four pointer variables. Then display these values by using
dereference operator with each pointer variable. Increment each pointer
variable and then again display these values by using dereference operator
with each pointer variable. (Discuss the output in the class room with your
teacher.)
28. Write a menu driven program which allows the user to perform the
following operations on a one dimensional array:
#4/6
36. Write a menu driven program which allows the user to perform the
following operations on a stack (Linked implementation):
1) Push
2) Pop
3) Display
37. Write a menu driven program which allows the user to perform the
following functions on a queue (Linked implementation):
1) Insert
2) Delete
3) Display
#5/6
#6/6