Download Programming using C++ Ex. No. : 1 Functions with default

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Programming using C++
Ex. No. : 1
Functions with default arguments and call by value,
address, reference
AIM:
To write a C++ program using functions with default arguments and call by
value, address, reference.
ALGORITHM:
Step 1: Defining the variable and function for cube, cuboids and cylinder.
Step 2: Declaring the function with one argument for cube and return type as integer.
Step 3: Declaring the function with three argument length, breadth, and height for
cuboids with return type double.
Step 4: Declaring the function with two argument radius and height for cylinder with
return type double.
Step 5: Calling the declared function with parameter value for cube, cuboid and
cylinder.
Step 6: Print the return value.
Step 7: Stop the process.
PROGRAM:
#include<iostream.h>
#include<conio.h>
double pi=3.14;
doublevolumeofcube (double a)
{
return (a*a*a);
}
doublevolumeofCuboids (double *l, double *b, int h=9)
{
return ((*l)*(*b)*h);
}
doublevolumeofCylinder (double &r, int h=8)
{
return (pi*r*r*h);
}
void main()
{
double r;
cout<<"\n Enter the radius of the cube:";
cin>>r;
cout<<"Volume of Cube :"<<volumeofcube(r)<<endl;
doublel,b;
cout<<"\n Enter the length and breath of the Cuboid :";
cin>>l>>b;
cout<<"Volume of Cuboid :"<<volumeofCuboids(&l,&b)<<endl;
cout<<"\n Enter the radius of the Cylinder :";
cin>>r;
cout<<"Volume of Cylinder:"<<volumeofCylinder(r)<<endl;
}
OUTPUT:
RESULT:
Thus the implementation of functions with default arguments and call by value,
address, referenceare executed successfully.
Ex. No. : 2
simple classes for understanding objects, member
functions & constructors
AIM:
To write a C++ program using objects, member functions & constructors.
ALGORITHM:
Step 1: Start the program.
Step2: Include necessary header files.
Step 3: Create class student with data members.
Step 4: Declare static member function.
Step 5: Declare show function to display the result
Step 6: End the program.
PROGRAM:
#include<iostream.h>
#include<conio.h>
class student
{
private:
static const int maxmark;
public:
int *v;
int sz;
char name[20];
staticintobjcount;
student()
{
objcount++;
}
voidsubjectcount(int size)
{
sz = size;
v = new int[size];
}
void read()
{
cout<<"Enter Student Name";
cin>>name;
int mark = 0;
for(int i=0;i<sz;i++)
{
constantrain:
cout<<"Enter mark for subject ["<<i+1<<"]";
cin>>mark;
if(mark>maxmark)
{
cout<<"Max should be less than or equal to "<<maxmark;
gotoconstantrain;
}
else
v[i]=mark;
}
}
void show()
{
int sum = 0;
cout<<"\nStudent Roll Number: "<<objcount;
cout<<"\nStudent Name : " <<name;
for(int i=0;i<sz;i++)
{
sum += v[i];
}
cout<<"Sum of Marks = " << sum;
}
void release()
{
delete v;
}
};
const int student::maxmark=100;
int student::objcount = 0;
void main()
{
student s1;
int count;
cout<<"Enter the Number of Subjects";
cin>>count;
s1.subjectcount(count);
s1.read();
s1.show();
s1.release();
student s2;
s2.subjectcount(count);
s2.read();
s2.show();
s2.release();
student s3;
s3.subjectcount(count);
s3.read();
s3.show();
s3.release();
}
OUTPUT:
RESULT:
Thus the implementation of objects, member functions &constructorsare
executed successfully.
Ex. No. :3(A)
Operator overloading using compile time polymorphism
AIM:
To write a C++ programfor operator overloadingusingcompile time
polymorphism.
ALGORITHM:
Step 1: Start the program.
Step2: Include necessary header files.
Step 3: Create class box with length, breadth, height.
Step 4: Declare Box1, Box 2, and Box 3 of type Box.
Step 5: Store the volume of a box in volume.
Step 6: Display the result.
Step 7: End the program
PROGRAM:
#include<iostream.h>
#include<conio.h>
class Box
{
double length;
double breadth;
double height;
public:
double getVolume(void)
{
return length * breadth * height;
}
void setLength( double len )
{
length = len;
}
void setBreadth( double bre )
{
breadth = bre;
}
void setHeight( double hei )
{
height = hei;
}
Box operator+(const Box& b)
{
Box box;
box.length = this->length + b.length;
box.breadth = this->breadth + b.breadth;
box.height = this->height + b.height;
return box;
}
};
int main( )
{
Box Box1;
Box Box2;
Box Box3;
double volume = 0.0;
Box1.setLength(6.0);
Box1.setBreadth(7.0);
Box1.setHeight(5.0);
Box2.setLength(12.0);
Box2.setBreadth(13.0);
Box2.setHeight(10.0);
volume = Box1.getVolume();
cout<< "Volume of Box1 : " << volume <<endl;
volume = Box2.getVolume();
cout<< "Volume of Box2 : " << volume <<endl;
Box3 = Box1 + Box2;
volume = Box3.getVolume();
cout<< "Volume of Box3 : " << volume <<endl;
return 0;
}
OUTPUT:
RESULT:
Thus the implementation of operator overloading using compile time
polymorphism is executed successfully.
Ex. No. : 3(B)
Function overloading using compile time
polymorphism
AIM:
To write a C++ programfor function overloading using compile time
polymorphism
ALGORITHM:
Step 1: Start the program.
Step2: Include necessary header files.
Step 3: Declare and define add function with parameter.
Step 4: Declare return type to display the output.
Step 5: End the program
PROGRAM:
#include<iostream.h>
#include<conio.h>
void add(int,int);
void add(int,int,int);
float add(float,int);
float add(float,float,int);
void add(int a,int b)
{
cout<<a<<" + "<<b<<" = "<<a+b;
}
void add(int a,int b,int c)
{
cout<<"\n"<<a<<" + "<<b<<" + "<<c<<" = "<<a+b+c;
}
float add(float a,int b)
{
return(a+b);
}
float add(float a,float b,int c)
{
return(a+b+c);
}
void main()
{
add(5,10);
add(5,10,15);
float a = 10.5;
int c = 12;
cout<<"\n"<<a<<" + "<<c <<" = "<<add(a,c);
float b = 12.6;
cout<<"\n"<<a<<" + "<<b<<" + "<<c<<" = "<<add(a,b,c);
}
OUTPUT:
RESULT:
Thus the implementation of function overloading using compile time
polymorphism is executed successfully.
Ex. No. : 4(A)
Inheritance using run time polymorphism
AIM:
To implement the inheritance and run-time polymorphism using C++.
ALGORITHM:
Step 1:
Defining the namespace, class, variable and function.
Step 2:
Class bank displays the customer name and account number.
Step 3:
Inherit properties of the class bank in newly created class savings.
Step 4:
Class savings to perform the deposit and withdraw process.
Step 5: Class current inherits with class savings to display the account information.
Step 6:
By creating the object for a class currentall the values are accessed and calling
the functions by object variable for performing banking operation.
Step 7:
Stop the process.
PROGRAM:
#include<iostream.h>
#include<conio.h>
class bank
{
public:
long int acno;
virtual void display()
{
cout<<"Account Number :"<<acno;
}
};
class savings : public bank
{
public:
int wdraw, dep, bal;
void saves()
{
int ch;
cout<<"Enter the A/c type,1.Deposit 2.Withdraw\n";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter the amount to be deposited = Rs.";
cin>>dep;
bal+=dep;
cout<<"Your A/c Balance is=Rs."<<bal<<endl;
break;
case 2:
cout<<"Enter the amount to be withdrawn = Rs.";
cin>>wdraw;
if(bal<wdraw)
{
cout<<"Unavailable Balance. Enter amount less than :" <<bal;
}
else
{
bal-=wdraw;
cout<<"Your A/c Balance is=Rs."<<bal<<endl;
}
break;
default:
cout<<"Invalid Choice";
break;
}
}
};
class current : public savings
{
public:
void display()
{
cout<<"Last amount withdrawn=Rs."<<wdraw<<endl;
cout<<"Last amount deposited=Rs."<<dep<<endl;
cout<<"Your A/c Balance is=Rs."<<bal<<endl;
}
};
int main()
{
int ch;
current ac;
ac.wdraw=ac.dep=ac.bal=0;
cout<<endl<<"Enter your A/c no.:";
cin>>ac.acno;
cout<<endl;
while(1)
{
cout<<endl<<"Account Number : "<<ac.acno<<endl;
cout<<"Enter the A/c type,1.Savings 2.Current 3.Exit\n";
cin>>ch;
switch(ch)
{
case 1:
ac.saves();
break;
case 2:
ac.display();
break;
case 3:
break;
default:
cout<<"Invalid Choice";
break;
}
if (ch==3)
break;
}
return(0);
}
OUTPUT:
RESULT:
Thus the implementation of inheritance using run time polymorphism is
executed successfully.
Ex. No. : 4(B)
Virtual functions
AIM:
To write a C++ program for virtual functions using run time polymorphism.
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the base class base.
Step 3: Declare and define the virtual function show().
Step 4: Declare and define the function display().
Step 5: Create the derived class from the base class.
Step 6: Declare and define the functions display() and show().
Step 7: Create the base class object and pointer variable.
Step 8: Call the functions display() and show() using the base class object and pointer.
Step 9: Create the derived class object and call the functions display () and show () using
the derived class object and pointer.
Step 10: Stop the program.
PROGRAM:
#include<iostream.h>
#include<conio.h>
class base
{
public:
virtual void show()
{
cout<<"\n Base class show:";
}
void display()
{
cout<<"\n Base class display:" ;
}
};
classdrive:public base
{
public:
void display()
{
cout<<"\n Drive class display:";
}
void show()
{
cout<<"\n Drive class show:";
}
};
void main()
{
base obj1;
base *p;
cout<<"\n\t P points to base:\n" ;
p=&obj1;
p->display();
p->show();
cout<<"\n\n\t P points to drive:\n";
drive obj2;
p=&obj2;
p->display();
p->show();
getch();
}
OUTPUT:
RESULT:
Thus the implementation of virtual functions using run time polymorphism is executed
successfully.
Ex. No. : 4(C)
virtual base classes
AIM:
To write a C++ programfor virtual base classesusing run time polymorphism.
ALGORITHM:
Step 1: Start the program.
Step2: Declare the class student.
Step 3:Declare and define the functions display () and show ().
Step 4: Declare the base class base.
Step 5: Student base class is inherited as virtual.
Step 6: Stop the program.
PROGRAM:
#include<iostream.h>
#include<conio.h>
class student
{
int rno;
public:
void getnumber()
{
cout<<"Enter Roll No:";
cin>>rno;
}
voidputnumber()
{
cout<<"\n\n\tRoll No:"<<rno<<"\n";
}
};
class test:virtual public student
{
public:
int part1,part2;
voidgetmarks()
{
cout<<"Enter Marks\n";
cout<<"Part1:";
cin>>part1;
cout<<"Part2:";
cin>>part2;
}
void putmarks()
{
cout<<"\tMarks Obtained\n";
cout<<"\n\tPart1:"<<part1;
cout<<"\n\tPart2:"<<part2;
}
};
class sports:public virtual student
{
public:
int score;
void getscore()
{
cout<<"Enter Sports Score:";
cin>>score;
}
void putscore()
{
cout<<"\n\tSports Score is:"<<score;
}
};
class result:public test,public sports
{
int total;
public:
void display()
{
total=part1+part2+score;
putnumber();
putmarks();
putscore();
cout<<"\n\tTotal Score:"<<total;
}
};
void main()
{
result obj;
obj.getnumber();
obj.getmarks();
obj.getscore();
obj.display();
getch();
}
OUTPUT:
RESULT:
Thus the implementation of virtual base classes using run time polymorphism is
executed successfully.
Ex. No. : 4(D)
Templates
AIM:
To write a C++ program for templates using run time polymorphism.
ALGORITHM:
Step 1: Defining the namespace, class, variable and function.
Step 2: Declaring the template class T.
Step 3: Declaring the get function for getting the value to bubble sort.
Step 4: Declaring the display function to display the value before bubble sorting.
Step 5: Declaring the sort function for bubble sorting process.
Step 6: The integer, float and character are bubble sorted.
Step 7: Separate object are created for bubble sorting integer, float and character.
Step 8: Stop the process.
PROGRAM:
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
template<class t>
class bubble
{
t a[25];
public:
void get(int);
void sort(int);
void display(int);
};
template<class t>
void bubble <t>::get(int n)
{
int i;
cout<<"\nEnter the array elements:";
for(i=0;i<n;i++)
cin>>a[i];
}
template<class t>
void bubble <t>::display(int n)
{
int i;
cout<<"\nThe sorted array is...\n";
for(i=0;i<n;i++)
cout<<a[i]<<setw(10);
}
template<class t>
void bubble <t>::sort(int n)
{
int i,j;
t temp;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
} } }}
int main()
{
bubble<int>obj1;
bubble<float>obj2;
bubble<char>obj3;
int w,n;
do
{
cout<<"\nBubble SORT\n";
cout<<"\n1.Integer Sort\t2.Float Sort\t3.Character Sort\t4.Exit\n";
cout<<"\nEnter Ur choice:";
cin>>w;
switch(w)
{
case 1:
cout<<"\nBubble Sort on Integer Values...";
cout<<"\nEnter the size of array:\n";
cin>>n;
obj1.get(n);
obj1.sort(n);
obj1.display(n);
break;
case 2:
cout<<"\nBubble Sort on Float Values...";
cout<<"\nEnter the size of array:\n";
cin>>n;
obj2.get(n);
obj2.sort(n);
obj2.display(n);
break;
case 3:
cout<<"\nBubble Sort on Character Values...";
cout<<"\nEnter the size of array:\n";
cin>>n;
obj3.get(n);
obj3.sort(n);
obj3.display(n);
break;
case 4:
break;
default:
cout<<"Invalid Choice\n";
break;
}}while(w!=4);
return(0);
}
OUTPUT:
RESULT:
Thus the implementation of templates using run time polymorphism is executed
successfully.
Ex. No. : 5(A)
File Handling - Sequential Access
AIM:
To write a C++ program using sequential access in files Handling.
ALGORITHM:
Step 1: Start the program.
Step2: Include necessary header files.
Step 3: Initialize character array.
Step 4: Open a file in write mode.
Step 5: Write inputted data into the file.
Step 6: Stop the program.
Step 7: Open a file in read mode.
Step 8: Again read the data from the file and display it.
Step 9: Stop the program.
PROGRAM:
#include <fstream.h>
#include<iostream.h>
#include<conio.h>
int main ()
{
char data[100];
ofstream outfile;
outfile.open("afile.txt");
cout<< "Writing to the file" <<endl;
cout<< "Enter your name: ";
cin.getline(data, 100);
outfile<< data <<endl;
cout<< "Enter your age: ";
cin>> data;
cin.ignore();
outfile<< data <<endl;
outfile.close();
ifstream infile;
infile.open("afile.txt");
cout<< "Reading from the file" <<endl;
infile>> data;
cout<< data <<endl;
infile>> data;
cout<< data <<endl;
infile.close();
return 0;
}
OUTPUT:
RESULT:
Thus the implementation of sequential access in file Handling is executed
successfully.
Ex. No. : 5(B)
File Handling - Random Access
AIM:
To write a C++ program using random access in files Handling
ALGORITHM:
Step 1: Start the program.
Step2: Include necessary header files.
Step 3: Create new text file test.txt.
Step 4: open the file using fopen.
Step 5: fwrite used to write content from one file to another.
Step 6: Stop the program.
PROGRAM:
#include<iostream.h>
#include<conio.h>
#include <string.h>
int main()
{
const char * filename="test.txt";
const char * mytext="Once upon a time there were three bears.";
intbyteswritten=0;
FILE * ft= fopen(filename, "wb") ;
if (ft)
{
fwrite(mytext,sizeof(char),strlen(mytext), ft) ;
fclose(ft ) ;
}
Cout<<"len of mytext = %i ",strlen(mytext);
return 0;
}
OUTPUT:
RESULT:
Thus the implementation of random access in file Handling is executed
successfully.
Programming using JAVA
Ex. No. : 6
String Handling in JAVA
AIM:
To write a java programforhandling strings
ALGORITHM:
Step 1: Start the program.
Step2: Create new object for class str.
Step 3: Create new string.
Step 4: Apply the string functions in the given string.
Step 5: Stop the program.
PROGRAM:
import java.lang.*;
class str
{
void stringhandlers()
{
String s=new String("ksriet") ;
String n1=s.substring(0,3);
String n2=s.substring(3);
System.out.println(" N1 =" + n1 + "N2=" + n2);
System.out.println("Upper Case" + s.toUpperCase());
System.out.println("Upper Case" + s.toLowerCase());
System.out.println("Replacing String" + s.replace("IET","CT"));
String s1=s.trim();
System.out.println("Before Trim" + s + "trim" + s1 +"sss");
System.out.println(s.charAt(1)) ; }
}
public class stringhandling
{
public static void main(String a[])
{
str s = new str();
s.stringhandlers(); } }
OUTPUT:
RESULT:
Thus the implementation of String Handling in JAVA is executed successfully.
Ex. No. : 7
Creating user defined packages
AIM:
To write a java programfordeveloping user defined packages
ALGORITHM:
Step 1: Start the program.
Step2: Create package Mypackage with class MyClass
Step 3:Create new object obj for the package
Step 4: Mypackage is imported in Myclass.
Step 5: Stop the program.
PROGRAM:
import MyPackage.*;
public class MyProg
{
public static void main(String a[])
{
MyClass o=new MyClass();
o.print(10);
}
}
MyPackage
package MyPackage;
public class MyClass
{
public void print(Object obj)
{
System.out.println("Value : " + obj);
System.out.println("Package Imported");
}
}
OUTPUT:
RESULT:
Thus the implementation of creating user defined packages is executed
successfully.
Ex. No. : 8(A)
User defined interfaces
AIM:
To write a java programfordeveloping user defined interfaces.
ALGORITHM:
Step 1: Start the program.
Step2: Create the interface super1, super2.
Step 3: Create subclass implements for super1, super2.
Step 4: Create classmultiple inheritance with object for subclass.
Step 5: Display the value
Step 6: Stop the program.
PROGRAM:
interface Super1
{
int A=10;
void PrintA();
}
interface Super2
{
int B=20;
void PrintA();
}
class Subclass implements Super1,Super2
{
int C=30;
public void PrintA()
{
System.out.println("Value of A =" + A);
}
public void PrintB()
{
System.out.println("Value of B =" + B);
}
void Print()
{
PrintA();
PrintB();
System.out.println("Value of C =" + C);
}
}
classmultipleinheritance
{
public static void main(String a[])
{
Subclass s = new Subclass();
s.Print();
}
}
OUTPUT:
RESULT:
Thus the implementation of user defined interfaces is executed successfully.
Ex. No. : 8(B)
Predefined Interfaces
AIM:
To write a java program for developing predefined interfaces.
ALGORITHM:
Step 1: Start the program.
Step2: Create class CollectionsDemo.
Step 3: Create an object for the new array list.
Step 4: Create an object for the linked list.
Step 5: Stop the program.
PROGRAM:
import java.util.*;
public class CollectionsDemo
{
public static void main(String[] args)
{
List a1 = new ArrayList();
a1.add("Zara");
a1.add("Mahnaz");
a1.add("Ayan");
System.out.println(" ArrayList Elements");
System.out.print("\t" + a1);
List l1 = new LinkedList();
l1.add("Zara");
l1.add("Mahnaz");
l1.add("Ayan");
System.out.println();
System.out.println(" LinkedList Elements");
System.out.print("\t" + l1);
}
}
OUTPUT:
RESULT:
Thus the implementation of predefined interfaces is executed successfully.
Ex. No. :9 (A)
Creation of threading in java
AIM:
To write a java program for creation of threading in java applications.
ALGORITHM:
Step 1: Start the program.
Step2: Create class ThreadSample extends from thread
Step 3: Create new class extthread.
Step 4: Create an object for the thread class.
Step 5: Create the corresponding catch block to catch the exception.
Step 6: Stop the program.
PROGRAM:
importjava.lang.*;
class ThreadSample extends Thread
{
public void run()
{
try
{
for(int i=5;i>0;i--)
{
System.out.println("Child Thread: " + i);
Thread.sleep(100);
}
}
catch(InterruptedException e)
{
System.out.println("Child Interrupted.");
}
System.out.println("Exiting Child Thread. ");
}
}
class extthread
{
public static void main(String a[])
{
ThreadSamplets = new ThreadSample();
ts.start();
try
{
for(int i=5;i>0;i--)
{
System.out.println("Main Thread: " + i);
Thread.sleep(100);
}
}
catch(InterruptedException e)
{
System.out.println("Main Thread Interrupted.");
}
System.out.println("Exiting Main Thread. ");
}
}
OUTPUT:
RESULT:
Thus the creation of threading in java applications is executed successfully.
Ex. No. : 9(B)
Multi-threading
AIM:
To write a java program for multi-threading.
ALGORITHM:
Step 1: Start the program.
Step2: Create class ThreadSample implementing the predefined interface runnable.
Step 3: Create an object for the thread class.
Step 4: Print the object of the thread class.
Step 5: Create the sleep method which suspends the thread.
Step 6: Declare a catch block for capturing the exception created by sleep method.
Step 7: Print the statement while exciting the child thread.
Step 8: Stop the program.
PROGRAM:
class ThreadSample implements Runnable
{
public void run()
{
try
{
for(int i=5;i>0;i--)
{
System.out.println("Child Thread: " + i);
Thread.sleep(100);
} }
catch(InterruptedException e)
{
System.out.println("Child Interrupted.");
}
System.out.println("Exiting Child Thread. ");
}}
class imprunnable
{
public static void main(String a[])
{
ThreadSamplets = new ThreadSample();
Thread T = new Thread(ts);
T.start();
try
{
for(int i=5;i>0;i--)
{
System.out.println("Main Thread: " + i);
Thread.sleep(100);
} }
catch(InterruptedException e)
{
System.out.println("Main Thread Interrupted.");
}
System.out.println("Exiting Main Thread. ");
}}
OUTPUT:
RESULT:
Thus the implementation of multi-threading executed successfully.
Ex. No. : 10(A)
Handling predefined exceptions
AIM:
To write a java programforhandling predefined exceptions.
ALGORITHM:
Step 1: Start the program.
Step2: Create class Exception Test
Step 3:Declare integer array
Step 4: Create the corresponding catch block to catch the exception.
Step 5: Stop the program.
PROGRAM:
import java.io.*;
public class ExcepTest{
public static void main(String args[])
{
Try
{
int a[] = new int[2];
System.out.println("Access element three :" + a[3]);
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Exception thrown :" + e);
}
System.out.println("Out of the block");
}
}
OUTPUT:
RESULT:
Thus the implementation of handling predefined exceptions is executed
successfully.
Ex. No. : 10(B)
Handling user defined exceptions
AIM:
To write a java programforhandling user defined exceptions.
ALGORITHM:
Step 1: Start the program. Declare integer array
Step2: Declare integer variable
Step 3: Create the classTException extending the exception class.
Step 4: Create another class TestException
Step 5: Check the condition.
Step 6: Create the corresponding catch block to catch the exception.
Step 7: Stop the program.
PROGRAM:
class TException extends Exception
{
TException(String msg)
{
super(msg);
}
}
class TestException
{
public static void main(String[]args)
{
int x=5,y=1000;
try
{
float z=(float)x/(float)y;
if(z<0.01)
{
throw new TException("NUMBER IS TOO SMALL....");
}
}
catch(TException e)
{
System.out.println("CAUGHT EXCEPTION!");
System.out.println(e.getMessage());
}
}
}
OUTPUT:
RESULT:
Thus the implementation of handling user defined exceptions is executed
successfully.
Additional Exercise for Practice
C++:
1. Write a ProgramFor Simple Class Example Program to Prime Number or not.
2. Write a C++ program for Students mark analysis using Static Data member,
Default Argument and Friend Function.
3. Write a C++ program for Students mark analysis using Static Data member,
Default Argument and Friend Function.
4. Design C++ classes with static members, methods with default arguments, friend
functions. (For example, design matrix and vector classes with static allocation,
and a friend function to do matrix-vector multiplication)
5. Write a Program for Addition of two distances of different object using Friend
Function in C++
6. Write a Program for Maximum of two distances of different object using Friend
Function in C++
7. Write a Program for Addition and Subtraction of Two Polynomial Object using
Operator Overloading in C++
8. Write a C++ program to Implement Matrix Class using Constructor, Destructor,
Copy Constructor, Overloading assignment operator.
9. Write a C++ program to implement complex number class with operator
overloading and type conversions such as integer to complex, double to complex,
complex to double.
10. Implement complex number class with necessary operator overloading and type
conversions such as integer to complex, double to complex, complex to double etc.
Implement Matrix class with dynamic memory allocation and necessary methods.
Give proper constructor, destructor, copy constructor, and overloading of
assignment
operator.
Overload the new and delete operators to provide custom dynamic allocation of
memory.
11. Write a C++ program to Overload the new and delete operators for addition of
vector elements to provide custom dynamic allocation of memory.
12. Write a Program for String concatenation using Operator Overloading concept in
C++
13. Write a Program for Implementation of Arithmetic Operations on Complex
numbers using Constructor Overloading in C++.
14. Write a Program for String concatenation using Dynamic Memory Allocation in
C++
15. Write a C++ program to implement the template of linked list class
16. Write a C++ program to implement the Templates of standard sorting algorithms
such as bubble sort, insertion sort, merge sort, and quick sort.
17. Write a Program for Implementation of Virtual Base Class in C++.
18. Define Point class and an Arc class. Define a Graph class which represents graph
as a collection of Point objects and Arc objects. Write a method to find a minimum
cost spanning tree in a graph.
19. Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square,
Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to
demonstrate dynamic polymorphism and RTTI.
20. Develop a template of linked-list class and its methods.
21. Design stack and queue classes with necessary exception handling.
22. Write a C++ program that randomly generates complex numbers (use previously
designed Complex class) and writes them two per line in a file along with an
operator (+, -, *, or /). The numbers are written to file in the format (a + ib). Write
another program to read one line at a time from this file, perform the
corresponding operation on the two complex numbers read, and write the result to
another file (one per line).
23. Write a C++ program to implement the Queue class with necessary exception
handling.
24. Write a Program for Student Grade Calculations in C++.
25. Write a Program for Employee Details in C++.
26. Write a Program for Convert Fahrenheit to Celsius in C++.
27. Write a Program for Implementation of Addition Operation of Octal Object in C++
28. Write a Program for Managing Bank Account using Inheritance concept in C++.
29. Write a Program for Area of different dimensions using Virtual Function in C++.
30. Write a Program for Implementation of Pure Virtual Function in C++.
Java:
1. Write a Program for Area of Different Dimension Using Interface in Java
2. Write a Program for Student Mark Details using Interface in Java.
3. Write a Program for Developing Packages in Java
4. Write a Program for Arithmetic operations in Java
5. Write a Program to Implement Exceptions in Java.
6. Write a Program for Largest of two numbers in Java
7. Write a Program for Addition of two numbers using Data Input Stream in Java.
8. Write a Program for Program to Implement Exceptions in Java.
9. Write a Program for Odd or Even using Data Input Stream in Java
10. Write a Program for Factorial using Data Input Stream in Java.