Program to multiply two polynomials

Program to multiply two polynomials(Source Code) // Program Ch02pr06 // Program to multiply two polynomials #include #include using namespace std; const int MAX = 10 ; class poly { private :  struct term { int coeff ; int exp ; } t[MAX] ; int noofterms ;  public :  poly( ) ; void polyappend ( int c, int e ) ; void polyadd ( poly &p1, poly &p2 ) ; [Read More]

Program to Add two polynomials

Program to Add two polynomials(Source Code) // Program Ch02pr05 // Program to Add two polynomials #include <iostream\> #include <conio.h\> using namespace std; const int MAX \= 10 ; class poly { private : struct term { int coeff ; int exp ; } t\[MAX\] ; int noofterms ; public : poly( ) ; void polyappend ( int c, int e ) ; void polyadd ( poly &amp;p1, poly &amp;p2 ) ; void display( ) ; } ; // initializes data members of class poly poly :: poly( ) { noofterms \= 0 ; for ( int i \= 0 ; i &lt; MAX ; i++ ) { t\[i\]. [Read More]

Program for matrix operations like determinant, singular, etc.

Program for matrix operations like determinant, singular, etc.(Source Code) #include #include #include using namespace std; const int MAX = 3 ; class matrix { private :  int mat[MAX][MAX] ;  public :  matrix( ) ; void create( ) ; void display( ) ; matrix matmul ( matrix &m ) ; matrix transpose( ) ; int determinant( ) ; int isortho( ) ; } ; // initializes the matrix mat with 0 [Read More]

Program to perform operations like addition, multiplicaton, etc. on matrix

Program to perform operations like addition, multiplicaton, etc. on matrix(Source Code) // Program Ch02pr03 // Program to perform operations like addition, multiplicaton, etc. on matrix #include #include using namespace std; const int MAX = 3 ; class matrix { private :  int **mat ; int sz1, sz2;  public :  matrix( int siz1, int siz2) ; void create( ) ; void display( ) ; void matadd ( matrix &m1, matrix &m2 ) ; [Read More]

Program to merge two 1-D arrays

Here is the program in cpp: #include <iostream.h> #include <conio.h> using namespace std; const int MAX1 = 5 ; const int MAX2 = 7 ; class array { private : int \*arr ; int size ; public : void create ( int sz ) ; void sort( ) ; void display( ) ; void merge ( array &a , array &b ) ; } ; // creates array of given size sz, dynamically void array :: create ( int sz ) { size = sz ; arr = new int\[size\] ; int n ; for ( int i = 0 ; i < size ; i++ ) { cout << "\\nEnter the element no. [Read More]

Representing Arrays as a class in cpp

Program to implement an array.(Source Code) // Program Ch02pr01 // Program to implement an array. #include using namespace std; const int MAX \= 100 ; class array { private : int arr\[MAX\] ; int N; int pos; public : void create(int i) { N\=i; int arr\[N\]; pos\=0; } void add(int n); void insert ( int pos, int num) ; void del ( int pos ) ; void reverse( ) ; void display( ) ; void search ( int num ) ; } ; void array::add(int n) { arr\[pos++\]\=n; } // inserts an element num at given position pos void array :: insert ( int pos, int num ) { // shift elements to right int i; for ( i \= N \- 1 ; i &gt;\= pos ; i\-\- ) { arr\[i\] \= arr\[i \- 1\] ; } arr\[i\] \= num ; } // deletes an element from the given position pos void array :: del ( int pos ) { // skip to the desired position int i; for ( i \= pos ; i &lt; N ; i++ ) arr\[i \- 1\] \= arr\[i\] ; arr\[i \- 1\] \= 0 ; } // reverses the entire array void array :: reverse( ) { for ( int i \= 0 ; i &lt; N / 2 ; i++ ) { int temp \= arr\[i\] ; arr\[i\] \= arr\[N \- 1 \- i\] ; arr\[N \- 1 \- i\] \= temp ; } } // searches array for a given element num void array :: search ( int num ) { // Traverse the array int i; for ( i \= 0 ; i &lt; N ; i++ ) { if ( arr\[i\] \=\= num ) { cout &lt;&lt; "\\n\\nThe element " &lt;&lt; num &lt;&lt; " is present at "&lt;&lt; ( i + 1 ) &lt;&lt; "th position" ; return ; } } if ( i \=\= N ) cout &lt;&lt; "\\n\\nThe element " &lt;&lt; num &lt;&lt; " is not present in the array" ; } // displays the contents of a array void array :: display( ) { cout&lt;&lt; endl ; // traverse the entire array for ( int i \= 0 ; i &lt; N ; i++ ) cout &lt;&lt; " " &lt;&lt; arr\[i\] ; } int main( ) { array a ; a. [Read More]

Why

I forget everything in studies and my things get misplaced so I decided to keep them safe on blogger.
So I decided to blog on it.