cpp

3 Comments

C++ class program to perform rational number arithmetic

Write a program to perform rational number arithmetic. #include<stdio.h> #include<iostream.h> #include<conio.h> class rational { int numer; int denom; public: void getdata() { cout<<"\n enter the numerator part of the rational no."; cin>>numer; cout<<"\n enter the denominator part of the rational no."; cin>>denom; } void operator+(rational); void operator-(rational); void operator *(rational); void operator /(rational); }; void […]

1 Comment

C++ program using class to multiply by 10 to every member of a list

Write a program using class which reads a list of N number of integer type in an array. It modifies the list by multiplying 10 to every number of the list. The modified list is displayed. #include<iostream.h> #include<conio.h> class array { public: void readarray(); void multiply(); }; void array::readarray() { int a[10]; cout<<"Enter the elements […]

22 Comments

C++ program to multiply two numbers without using multiplication operator

Write a c++ program to multiply two numbers without using multiplication operator. #include<iostream.h> #include<conio.h> void main () { int a,b,i,temp=0; clrscr(); cout<<"Enter Two numbers for multiplication"; cin>>a>>b; for(i=1;i<=b;i++) { temp=temp+a; } cout<<endl<<"Result are:: "<<temp; getch(); }

15 Comments

C++ program to illustrate Hybrid Inheritance.

C++ program to illustrate Hybrid Inheritance. #include<iostream.h> #include<conio.h> class stu { protected: int rno; public: void get_no(int a) { rno=a; } void put_no(void) { out<<"Roll no"<<rno<<"\n"; } }; class test:public stu { protected: float part1,part2; public: void get_mark(float x,float y) { part1=x; part2=y; } void put_marks() { cout<<"Marks obtained:"<<"part1="<<part1<<"\n"<<"part2="<<part2<<"\n"; } }; class sports { protected: […]

18 Comments

C++ program to implement three classes using multiple inheritance

MULTIPLE INHERITANCES AIM: Write a program to illustrating how all the three classes are implemented in multiple inheritance mode ALGORITHM • Start the process • Invoke the class M • Invoke the another class N • Invoke one more class,ie class P,which is inherited by both M and N • Create an object for class […]

1 Comment

C++ program for overloading the unary operator ++.

ALGORITHAM: • Start the process • Invoke the class counter • Crate two objects c1 and c2 • Assign values to c1 an c2 o Call c1.get_count() o Call c2.get_count() • Increment the values o C1++ o C2++ o ++c2 • Print c1 and c2 • Stop the process PROGRAM #include<iostream.h> #include<conio.h> class counter { […]

No Comments

c++ Program to illustrate the use of difference operators using friend function

AIM: A program to illustrate the use of difference operators to access the class member using friend function ALGORITHM: 1) Start the process 2) Invoke the classes 3) Call the set_xy() first a) Assign the value of x and y b) Print the value of x and y 4) Call the sum() for second(friend) a) […]

3 Comments

C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem

/* Write a C++ program that uses dynamic programming algorithm to solve the optimal binary search tree problem */ #include<iostream> #include<conio.h> #include<stdio.h> using namespace std; #define MAX 10 int find(int i,int j); void print(int,int); int p[MAX],q[MAX],w[10][10],c[10][10],r[10][10],i,j,k,n,m; char idnt[7][10];   main() { cout << "enter the no, of identifiers"; cin >>n; cout <<"enter identifiers"; for(i=1;i<=n;i++) gets(idnt[i]); […]

24 Comments

C++ programs for sorting numbers in ascending order using Quick sort method

/* Write C++ programs for sorting a given list of elements in ascending order using Quick sort sorting methods */ #include<iostream.h> #include<conio.h> int a[10],l,u,i,j; void quick(int *,int,int); void main() { clrscr(); cout <<"enter 10 elements"; for(i=0;i<10;i++) cin >> a[i]; l=0; u=9; quick(a,l,u); cout <<"sorted elements"; for(i=0;i<10;i++) cout << a[i] << " "; getch(); }   […]

54 Comments

C++ program that uses non-recursive functions to traverse a binary tree in Post-order

/* Write C++ program that uses non-recursive functions to traverse a binary tree in Post-order */ #include<iostream.h> #include<conio.h> #include<stdlib.h>   class node { public: class node *left; class node *right; int data; };   class tree: public node { public: int stk[50],top; node *root; tree() { root=NULL; top=0; } void insert(int ch) { node *temp,*temp1; […]


Electrofriends
Submit Your

Research Papers

Click Here to Submit

Electrofriends
Submit Your

Projects

Click Here to Submit

Free email signup

Get latest projects, articles in your mail box, subscribe to electrifriends

Email:
Recent Questions
    Technical Papers