You are on page 1of 2

C Questions

1. Twin Primes are defined to be two consecutive odd numbers which are both
primes. For example, 11 and 13 are twin primes. Write a program to generate all
the twin primes in a given range of numbers.

2. The ‘Solid Foundation’ wants to maintain items database in a text file. The item
record consists of item_code, item_name, item_price, item_qty.

Write a menu driven program which facilitate loading of existing items, adding
new items in database file and searching for specified item along with other
database facilities like modifying record, deleting record, displaying all item
records in selected sort order (ascending/descending) on selected field.

When items are increasing the search takes more time. Therefore it is decided to
maintain the index using linked list to search the items data. Add code to create
and use index for searching items records. The linked list node contains members
as item_code and position along with pointer to the next node.

3. A concordance is an alphabetical list of all the words in a text along with the
number of occurrences of each word.
Write a program that makes a concordance from an input text

4. An employee data file is kept sorted on employee name and contains,


qualification, place, date of joining, the name of the department in which the
employee works.

Write a program that prints the names of the employees in each department by
creating a temporary file for each department containing names of the employees
in that department, and then print the files.(if there are 4 departments then 4
temporary files will be created).

Finally create another text file which contains data of all employees sorted in
ascending order of department.

C++ Questions

1. Implement a stack class of ints. Include default constructor, a destructor, and the
usual stack operations: push (), pop (), isEmpty (), and isFull (). Use an array
implementation.

2. Implement a Time class. Each object of this class will represent specific time of
day, Storing the hours, minutes and seconds as integers. Include a constructor,
access functions, a function advance(int h, int m, int s) to advance the current time
of an existing object, function reset(int h,int m,int s) to reset the current time of an
existing object, and print() function.

3. Implement 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.

4. Implement a Circle class. Each object of this class will represent a circle, storing
its radius and the x and y coordinates of its center as floats. Include a default
constructor, Access functions, an area () function, and a circumference ()
function.

Modify the Circle class so that its data members are the float radius and the two
dimensional Point centre.

5. Write a class for Distance, containing data members, meters as int and centimeters
as int with member functions accept() and display(). Also overload the ++ and - -
operators and check them for pre-increment/decrement as well as post-
increment/decrement.

6. Write a Date class with members as day, month and year with member functions
accept () and display (). Overload the += operator to add number of days to a
given date.

7. Imagine a publishing company that markets both book and audio-cassette version
of its works. Create a class publication that stores the title (a string) and price
(type float) of publication. From this class derive two subclasses: book, which
adds a page count (type int); and tape which adds 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 putdata() function to display its data.

8. Write class Person and derive classes Employee and Contractor from it. From
Employee class derive WagedEmployee and Salaried Employee.

Assume necessary data members and member functions, with virtual member
functions accept() and display() in Person. Override these two virtual member
functions in each derived classes.

Test the classes by creating pointer to Person class and invoking accept() and
display() functions for objects of type Contractor, WagedEmployee and Salaried
Employee.

You might also like