C++ Practical File For Class Xii
C++ Practical File For Class Xii
3
complete the program to demonstrate the use of
inheritance.
22. 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. Text File
d) The number of small alphabets present in the file. (Reading)
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
23. Write a program to input the name of a text file from
the user. Then input a string and search for it in the
Text File
file and display the status whether it is present in the
(Reading)
file or not. The program should also check the existence
of the file in the beginning.
24. 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
file (which has been specified by the user) that don’t
end with a vowel. For example, if the original file Text File
contains (Reading and
Physical, Mental, or Emotional harm to anyone is a crime. – Writing)
Anonymous
Then the text file COPY.TXT shall contain
Physical, Mental, or Emotional harm is . – Anonymous
25. Write a program to perform SEARCH and REPLACE operation
on a text file. For this, input the name of a text file
from the user. Then input two characters and search for
Text File
the first character in the file and replace it with the
(Modification)
second character. Do it for all the occurances of the
first character in the text file. (Use a temporary file
for this purpose)
26. Declare a structure telerec in C++, containing name (20
characters) and telephone number. Write a program to
maintain a binary file of telephone records. The program
should allow the following functions on the file:
1) To append records in the file. Binary File
2) Display the name for a given telephone number. If the (Reading and
telephone number does not exist then display error Writing)
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".
27. 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
Binary File
C++ to do the following:
(Reading and
1) Given a blood group, display name, date of birth and
Writing)
phone number of all the persons of the given blood
group.
2) Append records in the file.
4
3) Input a telephone number and modify the corresponding
record.
28. Create two payroll files COMP1.DAT and COMP2.DAT. Each
of the files should have records with the following
fields:
EmpNo : Integer
Name : A string of 20 characters Binary File
Salary : A floating point number. (Reading and
Both the files should be created in the increasing order Writing)
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.
29. 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;}
Binary File
//function to return Book_name
(Reading,
int Rbook_name() {return Book_name;}
Writing, and
Modification)
};
1. Append Records
2. Modify a record for a given book no.
(Use seekg(), tellg() for this purpose)
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)
Note: (i) Use dynamic array for sorting of the file.
(ii) Use gotoxy() to display the formatted reports.
(iii) The program should be password protected.
30. Write a program to create a linked list in which each node Data Structures
contains the roll number and name of a student. Then (Self
perform search operations for name as well as roll no. on Referential
this list. Structures)
31. Write a menu driven program which allows the user to
perform the following operations on a one dimensional
Data Structures
array:
(Arrays)
Insertion, deletion, sorting (selection, insertion),
display.
32. Write a menu driven program to search an integer in a
list of integers using any of the following techniques.
Data Structures
(i) Linear Search
(Arrays)
(ii) Binary Search
Use bubble sort to sort the list, if required.
5
33. Write a program to input integer data in two arrays. Sort
one of the arrays in ascending order and the other in
descending order. Then merge them into a third array so Data Structures
that the data in the third array is in ascending order. (Arrays)
The program should then display the data from all the
three arrays.
34. Write a function in C++ which accepts an integer array
and its size as arguments/parameters and assigns 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: The resultant 2-D
Data Structures
array is:
(Arrays)
1 2 3 4 5 6 1 2 3
1 2 3 4 5 0 1 2 0
1 2 3 4 0 0 1 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0
6
40. Write a program using a stack to input a number and display
it as a product of its prime factors in the descending
order. E.g., if the number input is 252, then the output Data Structures
should be 7 x 3 x 3 x 2 x 2. (Stack)
(The smallest factor of any number is guaranteed to be a
prime)
7
Index for SQL
Name: _____________________________ Section: ___ Roll No.: ____
Consider the tables given below and answer the questions that follow:
Table: Employee
No Name Salary Zone Age Grade Dept
1 Mukul 30000 West 28 A 10
2 Kritika 35000 Centre 30 A 10
3 Naveen 32000 West 40 20
4 Uday 38000 North 38 C 30
5 Nupur 32000 East 26 20
6 Moksh 37000 South 28 B 10
7 Shelly 36000 North 26 A 30
Table: Department
Dept DName MinSal MaxSal HOD
10 Sales 25000 32000 1
20 Finance 30000 50000 5
30 Admin 25000 40000 7
9
50. Drop the tables Employee and Department.
10