Friday, May 21, 2010

String comparision comparing the whole string with a character and replace the matched character with that

//Author Subhasis Nayak(MCA,BBA,G-TECH)
//date:-20-05-2010
/*comparing the whole string with a character and replace the matched character with that  */
#include
#include
int main(){
int i,j;
char str[26];
char spe = ';';
//cin>>str;(this process will take the string untill you give a 'space')
cin.get(str,25);
cout<<"Your string is: "<
for(i = 0;i<26;i++){
    if(str[i] == spe){
        str[i] = '?';
    }
    else{
       }
}
cout<<
getch();
clrscr();
return 0;
}

Adding the TRANSPOSed MATRIX with original MATRIX

//Author Subhasis Nayak(MCA,BBA,G-TECH)
//date:-20-05-2010
/*adding the TRANSPOSed MATRIX with original matrix */
/*programming language C++*/
C Programming Language (2nd Edition)
#include
#include
int main(){
int i,j;
int arFirst[3][3];
int arSecon[3][3];

cout<<"Enter the value for Matrix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>arFirst[i][j];
        }
    }
 

cout<<"Displaying the Normal Matix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }


for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        arSecon[i][j] = arFirst[j][i];
       
        }
   
    }

cout<<"Displaying the Transpose Matix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }

cout<<"ADDING THE Matrix TO ITS TRANSPOSE ONE \n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
       
        }
    cout<
    }

getch();
clrscr();

 return 0;
}

write a program to reverse or transpose the matrix

//Author Subhasis Nayak(MCA,BBA,G-TECH)
//date:-20-05-2010
/*TRANSPOSe THE MATRIX  */
/*progrtamming language C++ */
#include
#include
int main(){
int i,j;
int arFirst[3][3];
int arSecon[3][3];
//Taking value for matrix
cout<<"Enter the value for Matrix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>arFirst[i][j];
        }
    }
//Dispaying the matrix
cout<<"Enter the value for Matrix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }

//transposing the matrix and passing to another matrix
cout<<"Transposed Matrix is\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        arSecon[i][j] = arFirst[j][i];
       
        }
   
    }
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
       
        }
    cout<
    }

getch();
clrscr();
return 0;
}

Thursday, May 20, 2010

write a program to add two matrix

//Author Subhasis Nayak(MCA,BBA,G-TECH)
//date:-20-05-2010
/*ADDING TWO MATRIX */
/*write a program to add two matrix */
/*proghramming language C++*/
#include
#include
int main(){
int i,j;
int arFirst[3][3];
int arSecon[3][3];
//takes values for first matrix from user
cout<<"Enter the value for the First Matrix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>arFirst[i][j];
        }
    }


//displaying the the first matrix
cout<<"Displaying the First Matix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }
//take value for second matrix
cout<<"Enter the value for the Second Matrix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>arSecon[i][j];
        }
    }
//displaying second matrix
cout<<"Displaying the second Matix\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }
//Dispaying the result
cout<<"Adding First And Second Matrix & displaying\n";
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cout<<<"\t";
        }
    cout<
    }
getch();
clrscr();
return 0;
}