Friday, September 26, 2014

Linear Algebra toolkit

This Linear Algebra Toolkit is composed of the modules listed below. Each module is designed to help a linear algebra student learn and practice a basic linear algebra procedure, such as Gauss-Jordan reduction, calculating the determinant, or checking for linear independence.
=====================================================
One of the most Important Tool used for solving Matrix and Matrix operations:

"Matrix Calculator"

Click Here-                             2 Click Here-                   3  Click Here-
=====================================================
Systems of linear equations and matrices
Row operation calculatorInteractively perform a sequence of elementary row operations on the given m x n matrix A.
Transforming a matrix to row echelon formFind a matrix in row echelon form that is row equivalent to the given m x n matrix A.
Transforming a matrix to reduced row echelon formFind the matrix in reduced row echelon form that is row equivalent to the given m x n matrix A.
Solving a system of linear equationsSolve the given system of m linear equations in n unknowns.
Calculating the inverse using row operationsFind (if possible) the inverse of the given n x n matrix A.
Determinants
Calculating the determinant using row operationsCalculate the determinant of the given n x n matrix A.



Tuesday, September 23, 2014

Pointers To Arrays in C++

Under Standing The concept of Pointer to array how the point any location in an array

#include<iostream.h>
void main()
{
int word[5]={2,6,4,7,8};
int *ptr;
ptr=word;

// For Values of array
cout<<" There are three way to print the value of this array "<<endl;
for(int i=0;i<5;i++)
{
cout<<endl<<" Value of word["<<i<<"] by simple index: "<<word[i];
cout<<endl<<" Value of word["<<i<<"] by *word:        "<<*(word+i);
cout<<endl<<" Value of word["<<i<<"] by *(ptr):       "<<*(ptr+i);
 }
// For Adresses of Array
cout<<"\n\t\tAdresses of Arrays\nThere are also three ways to find the adresses of this array"<<endl;
for(int k=0;k<5;k++)
{
cout<<endl<<" Adress of word["<<k<<"] by & operator   "<<&word[k];
cout<<endl<<" Adress of word["<<k<<"] by word:        "<<(word+k);
cout<<endl<<" Adress of word["<<k<<"] by (ptr):       "<<(ptr+k);
}
}

Monday, September 22, 2014

Pointers in C++

Pointer To Integers & Pointer To Pointer

**************************************************************************************
#include<iostream.h>
void main()
{
int var1=11;
int *ptr;
// pointer to integer
// dealing with pointer *ptr and integer vriable var1
ptr=&var1;
// Errors
//      *ptr=&var1;
//       ptr=var1;
//       var1=&ptr;
cout<<"Adress that pointer ptr is holding=                                      "<<ptr;
cout<<endl<<"Value of integer variable var=                                   "<<var1;
cout<<endl<<"Adress of var1 vriable using adress operator=              "<<&var1;
cout<<endl<<"Value of that variable for those this pointer is assign=  "<<*ptr;
cout<<endl<<"Own Address of pointer ptr=                                      "<<&ptr;

//dealing with pointer to pointer
int **ptr1;

//   Errors
// ptr1=var1;
// ptr1=ptr;
// ptr1=&var1;
// ptr1=&*ptr;
ptr1=&ptr;
cout<<endl<<"Adress that pointer** ptr1 is holding=            "<<ptr1;
cout<<endl<<"Adress that pointer* ptr is holding=               "<<*ptr1;
cout<<endl<<"Own adress of pointer** ptr1=                       "<<&ptr1;
cout<<endl<<"Adress that pointer* ptr is holding=                "<<&ptr;
cout<<endl<<"Value of variable that adress is saved in ptr*= "<<**ptr1;

//  Derefrencing addresses
var1=3;
*ptr=4;        // use all these three one by one and see the change in output
**ptr1=5;
 cout<<endl<<"\n\t var1=3 *ptr=4 **ptr1=5\n";
cout<<endl<<"Adress that pointer ptr is holding=                             "<<ptr;
cout<<endl<<"Value of integer variable var=                                  "<<var1;
cout<<endl<<"Adress of var1 vriable using adress operator=              "<<&var1;
cout<<endl<<"Value of that variable for those this pointer is assign= "<<*ptr;
cout<<endl<<"Own Address of pointer ptr=                                   "<<&ptr;
cout<<endl<<"Adress that pointer** ptr1 is holding=                      "<<ptr1;
cout<<endl<<"Adress that pointer* ptr is holding=                         "<<*ptr1;
cout<<endl<<"Own adress of pointer** ptr1=                                "<<&ptr1;
cout<<endl<<"Adress that pointer* ptr is holding=                         "<<&ptr;
cout<<endl<<"Value of variable that adress is saved in ptr*=          "<<**ptr1;

}

Sunday, September 21, 2014

C Program to find the Inverse of the Matrix

    #include<stdio.h> #include<math.h> float detrminant(float[][], float); void cofactors(float[][], float); void trans(float[][], float[][], float); void main() { float a[25][25], n, d; int i, j; printf("Enter the order of the matrix:\n"); scanf("%f", &n); printf("Enter the elemnts into the matrix:\n"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { scanf("%f", &a[i][j]); } } d = detrminant(a, n); printf("\nTHE DETERMINANT IS=%2f", d); if (d == 0) printf("\nMATRIX IS NOT INVERSIBLE\n"); else cofactors(a, n); } float detrminant(float a[25][25], float k) { float s = 1, det = 0, b[25][25]; int i, j, m, n, c; if (k == 1) { return (a[0][0]); } else { det = 0; for (c = 0; c < k; c++) { m = 0; n = 0; for (i = 0; i < k; i++) { for (j = 0; j < k; j++) { b[i][j] = 0; if (i != 0 && j != c) { b[m][n] = a[i][j]; if (n < (k - 2)) n++; else { n = 0; m++; } } } } det = det + s * (a[0][c] * detrminant(b, k - 1)); s = -1 * s; } } return (det); } void cofactors(float num[25][25], float f) { float b[25][25], fac[25][25]; int p, q, m, n, i, j; for (q = 0; q < f; q++) { for (p = 0; p < f; p++) { m = 0; n = 0; for (i = 0; i < f; i++) { for (j = 0; j < f; j++) { b[i][j] = 0; if (i != q && j != p) { b[m][n] = num[i][j]; if (n < (f - 2) n++; else { n = 0; m++; } } } } fac[q][p] = pow(-1, q + p) * detrminant(b, f - 1); } } trans(num, fac, f); } void trans(float num[25][25], float fac[25][25], float r) { int i, j; float b[25][25], inv[25][25], d; for (i = 0; i < r; i++) { for (j = 0; j < r; j++) { b[i][j] = fac[j][i]; } } d = detrminant(num, r); inv[i][j] = 0; for (i = 0; i < r; i++) { for (j = 0; j < r; j++) { inv[i][j] = b[i][j] / d; } } printf("\nTHE INVERSE OF THE MATRIX:\n"); for (i = 0; i < r; i++) { for (j = 0; j < r; j++) { printf("\t%2f", inv[i][j]); } printf("\n"); } }

Saturday, September 20, 2014

Data Structure Programs

Read Also:  


"All Data Structure Programs up-till now"

To get code Click on that program heading :) ☺ ☻ 

 ALL Type Of Sorting Click here :: most important :: 

-------------------

`Queues 

----------------

`Single Link-List:

*  How to create single Link-list in C++

*  Insertion at any point in link-list in C++

*  Concatenate or Merge two Link-lists in C++

Deletion At any point in Circular Link List in C++
------------------------------------

`Double Link-list:

=================

Stacks Data Structure:


Decimal to binary conversion using stack in c++
============ 

How to add two matrix size is define by use






Program to print counting 10 to 1 using Recursion

--------------------------------------------------



Program to print counting 1 t0 10 using Recursion

#include<iostream.h>
#include<conio.h>
void myfuntion(int);
void main()
{
clrscr();
myfuntion(1);
}
void myfuntion(int counter)
{
if(counter==11)
return;
else
{
cout<<"\ncounter= "<<counter;
myfuntion(++counter);
return;
}
}

C++ Program to find Fibonacci sequence

#include<iostream.h>
#include<conio.h>
int fib(int);
void main()
{
clrscr();
int a=0;
cout<<"\nEnter a no that u want to know fibnocci sequense of: ";
cin>>a;
cout<<fib(a);
}
int fib(int no)
{
if(no==0)
return 0;
else if(no==1)
return 1;
else
return fib(no-1)+fib(no-2);
}

Saturday, September 13, 2014

Insertion And Deletion in array at any point

#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,c=0,d,no,j;
cout<<"\nenter the size af array :";
cin>>a;
int *x=new int[a];
cout<<"\n Now the size of array is= "<<a; x[a]=NULL;
cout<<"\n first enter a no of values u want enter: ";
cin>>b;

for(int q=1;q<=b;q++)
{
cout<<"\n enter a value for x["<<q<<"] =";
cin>>x[q]; c++;
}
{
for(int w=1;w<=b;w++)
cout<<"\n The value u enter at "<<w<<"is "<<x[w];
}
cout<<"\n Displaing whole array :";
for(int i=1;i<=a;i++)
cout<<"\n the value at index "<<i<<" is "<<x[i];
cout<<"\n Total values u enter right now are \"counter=\""<<c;
cout<<"\n\n----________-----_-----__---_-_--------_---_-_-_--_-__-_-_-__-";
cout<<"\n\t INSERTION\n\n enter index u want to insert value";
cin>>d;
if(c>a)
cout<<"\n sorry no space in array";
else
{{
for(j=c;j>=d;j--)
x[j+1]=x[j];

}
cout<<"\n Enter value at index "<<d;
cin>>no;
x[d]=no;c++;
}
  cout<<"\n Displaing whole array :";
for(int r=1;r<=a;r++)
cout<<"\n the value at index "<<r<<" is "<<x[r];
cout<<"\n Total values u enter right now are \"counter=\""<<c;
 clrscr();
  cout<<"\n\n----________-----_-----__---_-_--------_---_-_-_--_-__-_-_-__-";
cout<<"\n\t DELETION\n\n enter index u want to delet value";
cin>>d;
{{
for(j=d;j<=c;j++)
x[j]=x[j+1];

} c--;
cout<<"\n Displaing whole array :";
for(int r=1;r<=a;r++)
cout<<"\n the value at index "<<r<<" is "<<x[r];
cout<<"\n Total values u enter right now are \"counter=\""<<c;
} }

Wednesday, September 10, 2014

Saturday, September 6, 2014

CONSOLE COLOUR CHANGING IN C++

Structure of the Problem Requirements 

In this problem we will learn about the color changing in Console in C++ Program. For changing colour of text or background we include the windows.h class in C++ program. Windows library deal with such a events. In our program we make an instance of handle class and then use it to change the colour of the required lines. Here is the source code of this problem which help you in better understanding.


SOURCE CODE


#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"\t \t \t \t LEP \n \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<" CEO & Founders  :" <<" Usman Siddique \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"  Developers      :" <<" Hafiz muhammad usman siddique \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"  Website         :" <<" pcphunt.blogspot.com \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<"  Facebook Address:" <<" https://www.facebook.com/usman.siddique.7771 \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"   Address :" <<"Comsats  \n " <<endl;
}