Saturday, January 17, 2009

Created a program with basic programing that find echilon form.

its only basic programing in C++ with logic I created.
it was very difficult task for me to create such code with my own logic.
although there are bugs still i am not able to fix them.
here is the code


#include
#include
#include
void main()
{
float a[3][4];
int i=0,j=0,n=0,m=0,c[4],k=0;
char b;
for(i=0;i<=2;i++)
{
n++;
for(j=0;j<=3;j++)
{
m++;
cout<<"enter "<<'A'< cin>>a[i][j];
clrscr();

}
m=0;
}


cout << "the matrix you enter is"<<"\a\a\a"< for(i=0;i<=2;i++)
{
for(j=0;j<=3;j++)
cout<<"\t"< cout<
}
if(a[0][0]==0)
{
for(i=0;i<=3;i++)
{
c[i]=a[0][i];
a[0][i]=a[1][i];
a[1][i]=c[i];
}
}
if(a[0][0]!=0)
{
if(a[0][0]!=1)
{
k=a[0][0];
for(j=0;j<=3;j++)
{
a[0][j]=a[0][j]/k;
}
}
}
if(a[0][0]==0)
{
for(i=0;i<=3;i++)
{
c[i]=a[0][i];
a[0][i]=a[2][i];
a[2][i]=c[i];
}
}
if(a[0][0]!=0)
{
if(a[0][0]!=1)
{
k=a[0][0];
for(j=0;j<=3;j++)
{
a[0][j]=a[0][j]/k;
}
}
}
if(a[0][0]!=0)
{
if(a[0][0]!=1)
{
k=a[0][0];
for(j=0;j<=3;j++)
{
a[0][j]=a[0][j]/k;
}
}
}
if(a[1][0]!=0)
{
k=a[1][0];
for(j=0;j<=3;j++)
{

a[1][j]=a[1][j]-k*a[0][j];
}
}
if(a[2][0]!=0)
{
k=a[2][0];
for(j=0;j<=3;j++)
{

a[2][j]=a[2][j]-k*a[0][j];
}
}
if(a[1][1]==0)
{
for(i=0;i<=3;i++)
{
c[i]=a[1][i];
a[1][i]=a[2][i];
a[2][i]=c[i];
}
}
if(a[1][1]!=0)
{
if(a[1][1]!=1)
{
k=a[1][1];
for(j=0;j<=3;j++)
{
a[1][j]=a[1][j]/k;
}
}
}
if(a[2][1]!=0)
{
k=a[2][1];
for(j=0;j<=3;j++)
{

a[2][j]=a[2][j]-k*a[1][j];
}
}
if(a[2][2]!=0)
{
k=a[2][2];
for(j=0;j<=3;j++)
{
a[2][j]=a[2][j]/k;
}
}






cout << "Echelon form of this matrix is"<<"\a\a\a"< for(i=0;i<=2;i++)
{
for(j=0;j<=3;j++)
cout<<"\t"< cout<
}



getch();
}




No comments:

Post a Comment