Post on 14-Oct-2015
description
1. QUADRATIC EQUATION USING CONSTRUCTORAim:
To write a c++ program for problem number and using constructor to initialize thenumber.Algorithm:Step1: Start the program.Step2: Create the class and declare the required number variable and member function.Step3: Initialize the data member using constructor and assign value.Step4: Using appropriate function calculates the simple interest and display.
Simple interest using display() function.Step5: In the main() function create the object and using object call the method of the class.Step6: Stop the program.
Sample input and output:ENTER THE A, B, C VALUES:121THE ROOTS ARE REAL AND EQUAL:132THE ROOTS ARE IMAGINARYTHE ROOTS ARE:-1+1.732051i-1-1.732051iResult:
Thus the above program has been successfully executed.
2. A SIMPLE PROGRAM USING CLASS AND OBJECTSAim:
To write a C++ program to initialize a member function using class and objects.Algorithm:Step1: Start the program.Step2: Create a class and declare the required variable in private section.Step3: In public create a necessary function to get the inputs, apply the
function to print the values.Step4: In main function create an object and call the class.Step5: Stop the program.
Enter the rate of interest 2Si=2
Result:Thus the above program was successfully executed and the output was verified.
3. PRIVATE MEMBER FUNCTIONAim:
To write a c++ program to implement a private member function.Algorithm:Step1: Start the program.Step2: Create a class and declare a required variable and require a design member function asprivate.Step3: In public function create a static member function to call the private function.Step4: To display the required output.Step5: Create a class object using main().Step6: Stop the program.
// Private Member Function#include#includeclass simple{private:float l,b,area;void read(){coutl>>b;}public:void sd(){read();}void call();{
4(a).OVERLOADING A BINARY OPERATOR TO PERFORMADDITION OF TWO COMPLEX NUMBERS.
Aim:To write a C++ program to overloading binary operator to perform adding of complex
number.Algorithm:Step1: Start the program.Step2: To declare the class name complex and define the function.Step3: And then read operation and calculate the values.Step4: Display the value by using the void display() function.Step5: Then to create a object and utilities the value.Step6: Stop the program.
//Operator Overloading#include#includeclass complex{float x,y;public:complex(){}complex(float real,float image){x=real;y=imag;}friend complex operator+(complex,complex);void display(();};complex operator+(complex c,complex d){complex temp;temp.x=c.x+d.x;temp.y=c.y+d.y;return(temp);
4(b).OVERLOADING A BINARY OPERATOR TO PERFORMTHE OPERATION CONCATINATION OF TWO STRINGS
Aim:To write a C++ program to overloading binary operator to perform adding of complex
number.Algorithm:Step1: Start the program.Step2: To declare the class name complex and define the function.Step3: And then read operation and calculate the values.Step4: Display the value by using the void display() function.Step5: Then to create a object and utilites the value.Step6: Stop the program.
}void main(){clrscr();complex c1(vijay);c1.display();complex c2(sangeetha);c2.display();complex c3=c1+c2;c3.display();getch();}
Sample input and output:VijaySangeethaVijaysangeetha.
Result:Thus the above program was successfully executed and the output was verified
RE
5. STATIC DATAMEMBERSAim:
To write a c++ program to implement static data members.Algorithm:Step1: Start the program.Step2: To declare the data member function static data and count value.Step3: Declare the value get data these get count function.Step4: write value for member value a decrement the value count.Step5: The three values are declared in main functional a, b, c.Step6: The value is declared in values.Step7: The last return statement.Step8: Stop the program.
6. STATIC MEMBER FUNCTIONAim:
To write a c++ program to implement static member function.Algorithm:Step1: start the program.Step2: To declare the data member function static data and count value.Step3: Declare a value get data then get count function.Step4:Write a value for member value a decrement ,the value count it.Step5: Stop the program.
t1.setcode();t2.setcode();t3.setcode();test::showcount();t1.showcode();t2.showcode();t3.showcode();getch();terurn 0;}
Sample Input And Output:***********************count:3objectno:1objectno:2objectno:3
Result:Thus the above program was successfully executed and output was verified.
7. STUDENTS DETAILS USING ARRAY OF OBJECTSAim:
To write a c++ program to implement array on object to accept and display the studentdetails.Algorithm:Step1: Start the program.Step2: Object the classes there are scan of array object to student marks enter the integer values.Step3: Increase the value of array on object.Step4: The functional calls mark in student object.Step5: Stop the program.
//Student Details Using Array Objects
#include#includeclass stud{private:char name[100];int m1,m2,m3,tot,no;float avg;public:void get(){cout
Sample input and output:**********************Enter the no of student details u process: 3Enter the student no: 01Enter the student name: MayaEnter the three subject marks:788675Enter the student no: 02Enter the student name: ManiEnter the three subject marks:867596
The student processed details are:No Student name Total Percentage01 Maya 239 79.6602 Mani 257 85.66
Result:Thus the above c++ program was successfully executed and output was verified.
8. IMPLEMENTATION OF COPY CONSTRUCTOR
Aim:To implement the queries using SQL.
Algorithm:Step1: Start the program.Step2: Object of the class then is the same of the copy constructor then the values.Step3: Declare the data member in private section.Step4: Declare the constructor add copy constructor in the private section.Step5: Create the object in the main function and of object as function argument using
ConstructorStep6: Stop the program.
9. IMPLEMENTATION OF FRIEND FUNCTION
Aim:To write a c++ program to implement friend function.
Algorithm:Step1: Start the program.Step2: Create the class declares and initialize to variable to friend in public section.Step3: In outside of the class reference as assurance and receive the friend function.Step4: Using the object reference to case the data member in class as return the processed
values.Step5: In main function create the object and pass the object as function and can true series
function.Step6: Stop the process.
Sample input and output:************************THE RESULT IS: 300
Result:Thus he above program was successfully executed and output was verified.
10. IMPLEMENTATION OF RETURNING OBJECTAim:
To write a c++ program to implement returning object.Algorithm:Step1: Start the program.Step2: Create a class declares the data member and member function and friend function.Step3: Input the values from the keyboard to the input function.Step4: Sum function is used to sum to complex values.Step5: Create the object to the main function display the sum of the two complex member the
display functionStep6: Stop the program.
11. UNARY OPERATOR OVERLOADING
Aim:To write a C++ program to implement Unary Operator Overloading.
Algorithm:Step1: Start the programStep2: To create a class name un.Step3: To create a Function of a classStep4: To using the Unary Operator and Decrement Operator.Step5: To create the objects of the class.Step6: Display the values to call the function using objects.Step7: The last return the Statement.Step8: Stop the Program.
12. DATA CONVERSIONAim:
To write a C++ program using Data Conversion.Algorithm:Step1: Start the ProgramStep2: Create the class S.Step3: Declare the variable code.Step4: Declare the define the operator function in the public section.Step5: Create the Main FunctionStep6: Create the object d declare variable inStep7: Convert the objects and data the integer data.Step8: Stop the Program.
13. POINTER TO OBJECTAim:
To write a C++ Program to implement the Pointer to ObjectsAlgorithm:Step1: Start the programStep2: Create the class name S.Step3: Declare the class Variable i,n,r,s.Step4: Declare and define the member function is public section, get(), void cal(),
void disp().
Step5: Start the main program.Step6: Create the Objects with Pointer.Step7: Call the function S->get(), S->cal(), S->disp().Step8: Stop the Program.
};void main(){clrscr();si*s;s->get();s->cal();s->disp();getch();}
Sample Input and Output:Enter the Principle Value: 1500Enter the Number of Periods: 1Enter the Rate of Interest: 2
Si=30
Result:Thus the C++ Program was executed successfully and Output is verified.
14. STUDENT DETAILS USING SINGLE INHERITANCEAim:
To write a C++ program to implement Student Details Using Single Inheritance.Algorithm:Step1: Start the Program.Step2: Create the basic class name stud.Step3: Declare and define the function void get().Step4: Create the derived class name d stud in base class stud.Step5: Declare the variables marks, tot, avg.Step6: Declare the function void get marks(), void cal(), void display().Step7: Start the main program.Step8: Create the objects d to derived class d studStep9: Call the function.Step10: Stop the program.
}Sample Input and Output
~~~~~~~~~~~~input~~~~~~~~~~~~Enter the Student No: 01Enter the Student Name: SudhaEnter the 5 Subject Mark: 98 89 78 98 88~~~~~~~~~~~~output~~~~~~~~~~~~The Student Name= SudhaThe Student No= 1Total= 451Avg= 90
Result:Thus the C++ program was executed successfully and output is verified.
15. VIRTUAL FUNCTIONAim:
To write a C++ program to implement the Virtual Function.Algorithm:Step1: Start the Program.Step2: Create the class names.Step3: Declare the Virtual Function, using virtual keywordStep4: Create the define class d in base class s.Step5: Start the main program.Step6: Create objects in derived class and create the pointer objects in base class.Step7: Call the disp() function using & Pointer Object.Step8: Stop the Program.
h->disp();h=&e;h->disp();getch();}
Sample Input and OutputBase class display functionDerived class functionResult:
Thus the C++ program was executed successfully and output is verified.
16. VIRTUAL BASE CLASSAim:
To write a C++ program to implement the Virtual Base Class.Algorithm:Step1: To start the program.Step2: Create the base class name a.Step3: Declare the member function.Step4: Create the Virtual derived class f from base class a.Step5: Create the derived class from class s and cStep6: Create the derived class from base class a.Step7: Start the main program.Step8: Create the objects for the derived class dStep9: Call the function using objectsStep10: Stop the program.
Result:Thus the C++ program was executed successfully and output is verified.
17. THIS POINTERAim:
To write a C++ program to implement the This Pointer.Algorithm:Step1: To start the programStep2: Create the class name person.Step3: Declare the variable new age.Step4: Create the function declare the pointer variable strcpy pointer variable.Step5: Return the This Pointer.Step6: Create the main program.Step7: Create the object c1,c2,c3 assign.Step8: Call the function.Step9: Stop the program.
Result:Thus the C++ program was executed successfully and output is verified.
18. MULTIPLE INHERITANCEAim:
To write a C++ program to implement a Multiple Inheritance.Algorithm:Step1: To start the programStep2: Declare a class name student having get() function which tabs input about
Student no and name.
Step3: Create another class student details which marks from user on input.Step4: Create another class output which inheritance student and student details
class in
which output functions define in which calculate total marks.
Total=Math+Science+English
Display all details.
Step5: Stop the program.
Student Name: Sudhakar
Total Marks: 283
Average Mark: 94.333336
Result:Thus the C++ program was executed successfully and output is verified.
19. POINTER TO DERIVED CLASS OBJECTSAim:
To write a C++ program to implement the Pointer to Derived Class Objects.Algorithm:Step1: To start the program.Step2: Create the class name s.Step3: Create the virtual function in public section.Step4: Declare the pointer object *b.Step5: Stop the program.
Bptr Now Points to Derived ObjectB=200Dptr is Derived Type Pointer=200D=300Using((dc *)bptr)=200D=400
Result:Thus the C++ program was executed successfully and output is verified.