C++ class program to perform rational number arithmetic

Sunday, April 4th, 2010  »  Posted By  »  Total 3 Comments

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 […]

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

Sunday, April 4th, 2010  »  Posted By  »  Total 1 Comment

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 […]

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

Sunday, April 4th, 2010  »  Posted By  »  Total 17 Comments

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(); }

C++ program to illustrate Hybrid Inheritance.

Saturday, March 13th, 2010  »  Posted By  »  Total 13 Comments

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: […]

C++ program to implement three classes using multiple inheritance

Saturday, March 13th, 2010  »  Posted By  »  Total 11 Comments

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 […]

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

Saturday, March 13th, 2010  »  Posted By  »  Total 1 Comment

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 { […]

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

Saturday, March 13th, 2010  »  Posted By  »  Total 0 Comment

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) […]

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

Thursday, March 11th, 2010  »  Posted By  »  Total 2 Comments

/* 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]); […]

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

Thursday, March 11th, 2010  »  Posted By  »  Total 21 Comments

/* 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(); }   […]

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

Thursday, March 11th, 2010  »  Posted By  »  Total 54 Comments

/* 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; […]

Question and Answer
C/C++ Unix & Linux Wordpress
Source codes
C C++ Java

Free email signup

Email: