Você está na página 1de 7

PGDAC (C++ )

LAB Assignment to be submitted on 14 th OCT 2016


(A4 size sheets)
1. An electricity board charges the following rates to domestic users ti discourage large
consumption of energy:
FOR the first 100 units - 60P per unit
For next 200 units - 80P per unit
Beyond 300 units - 90P per unit
All users are charged a minimum of Rs.50.00. if the total amount is more than Rs.300.00 than
an additional surcharge of 15% is added
Write a C++ program to read the names of users and number of units consumed and print out
the charges with names

2. Write a C++ program to implement a telephone bill class with Name, Address, Tel. No.,
No. of calls as data members. Compute the amount to be paid if the charges per call is
Rs. 2/3. Find whether given number is prime or not.
4. Find whether given number is palindrome or not.
(Ex : 34543)

5. Write a C++ program to print the following by reading number of rows to be printed from
the user
*
**
***
****
*****
a) A
A
A
A
A
A

B
B
B
B
B

C
C D
C D E
C D E F

b) A B C D E E D C B A
ABCD
DCBA
ABC
CBA
AB
BA
A
A

6. Write a C++ program to print the Fibonacci series 0 1 1 2 3 5 8 13 . By getting number


of number to be displayed is given as input
7 . Create a Structure called employee with the following details as variables within it.
1. Name of the employee
2. Age
3. Designation
4. Salary
Write a C++ program to create array of objects for the structure to access these and print the
name, age, designation and salary

8. Write a C++ program to find the number of vowels present in the given character array using
Pointer
9. Write a C++ program to print the given number in reverse order. Use functions with return
type
and without return type for reversing the number
10. Create a class for counting the number of objects created and destroyed within various block
using constructor and destructors.
11. Write a C++ program to create three objects for a class named pntr_obj with data members
such
as roll_no & name . Create a member function set_data() for setting the data values and print()
member function to print which object has invoked it using this pointer
12. Write a C++ program to explain virtual function (polymorphism) by creating a base class
c_polygon which has virtual function area(). Two classes c_rectangle and c_traingle derived
from c_polygon and they have area() to calculate and return the area of rectangle and triangle
respectively.
13. Programs to Overload Unary & Binary Operators as Member Function & Non

Member Function.
a. Unary operator as member function
b. Binary operator as non member function
14. Write a C++ program to count the number of persons inside a bank, by increasing count
whenever a person enters a bank, using an increment(++) operator overloading function, and
decrease the count whenever a person leaves the bank using a decrement(--) operator
overloading function inside a class
15. Write a program to accept the student detail such as name and 3 different marks by get_data()
method and display the name and average of marks using display() method. Define a friend
class for calculating the average of marks using the method marrk_avg().
16. Write a program to explain class template by creating a template T for a class named pair
having two data members of type T which are inputted by a constructor and a member function
get-max() return the greatest of two numbers to main. Note: the value of T depends upon the
data type specified during object creation
17.

18.

Sort the elements in a given array, using bubble sort.

Write a C++ program to implement flight class with data member as flight no.,
source, destination and fare. Write a copy constructor and a member
function to display the flight information.

19. program to add two time entered by user


20.

Write a C + + program to implement matrix class. Add member function to


transpose the matrix.

21. Write a C++ program to implements a string class. Overload + Operator to


concatenate two strings.

22. Write a C++ program to find the number of characters, word and lines in the given text as
input.
23.Read all the records in a given sequential file

24 Develop a template of linked-list class and its methods


25. Develop templates of standard sorting algorithms such as bubble sort, insertion sort,
merge sort, and quick sort.
26. Write C++ program to overload new and delete operators to provide custom dynamic
memory allocation.
HINT
void *operator new(size_t size)
{
void *v;
cout<<"\nOperator new invoked...";
v=malloc(size);
if(!v)
{

cout<<"Unable to allocate memory";


exit(0);
}
return v;
}
void operator delete(void* v)
{ cout<<"\nOperator delete invoked...";
free (v);}}

27. write a C++ program for bubble sort using template

28. To write a program to find the multiplication values and the cubic values using inline
function.
29 To find out the student details using multiple inheritance
30. Write a program that ask divide two number and if denominator is zero then throws
exception
31.write a program that performs dynamic memory allocation . ans ask size of pointer from user .
is size is greater then 50 thro exception else ask students marks and display then .
32. write a program that ask file name from user . Print its contents .If file not found throw
exception
33 Write a program to count words in file .
34. A C++ function, that reads the file FIRST.TXT and creates a new file named SECOND.TXT,
to contain only those words from the file FIRST.TXT which start with a lowercase vowel
35. Assuming the class EMPLOYEE given below, write functions in C++ to perform following:
(i) Write the objects of EMPLOYEE to a binary file.
(ii) Read the objects of EMPLOYEE from binary file and display them on screen

36. Write three derived classes inheriting functionality of base class person (should have a
member function that ask to enter name and age) and with added unique features of student, and
employee, and functionality to assign, display records of student and employee. And make one
member function for printing address of the objects of classes (base and derived) using this
pointer.

37. Create two objects of base class and derived classes each and print the addresses of
individual objects.
38. Program to accept a character in any case and print in another case.
39. c program to get ip address
40. Program to print smallest of four no byusing ternary operators
HINT
small=(a<b)?(a<c)?(a<d)?a:d:(c<d)?c:d:(b<c)?(b<d)?b:d:(c<d)?c:d; printf(biggest of the
given 4 numbers IS%d,small);
41.Re a d a v a l u e o f d i s t a n c e f r o m o n e o b j e c t a n d a d d w i t h a v a l u e i n
a n o t h e r object using friend function
42. Write a program to find if two strings are anagrams
43. Write a C++ program to compress string
Example aaabbbccdd
Output a3b3c2d2
44. Program for finding simple interest using constructor with default arguments .
45. Program to pass an entire array to the function using pointer to an array of integer
46.write a program to encrypt a string using Caesar cipher, encryption rule.

47. C++ program to find if two strings are anagrams .


48. Use the command line argument to read the argument given by the user and using that

make the program which copy the content of one file to the another file.
49 . Create a class having integer array and create sorting function .In main create menu
driven program that ask choice from user
1 perform bubble sort
2 perform quick sort
3 insertion sort
4

selection sort

5.Reverse array
6.Search particular element from array and print its position .

50 .Create class person having fields like name , age . and virtual methods get and show.
Override these methods in derived class named EMP and call EMP methods in main using
base class pointer .

Você também pode gostar