u

Wednesday, 6 June 2012

C++ PROGRAM Inputting NINE INPUTS AND TREATS THE INPUTS AS COMPONENTS OF THREE DIMENSIONAL MATRIX AND CALCULATES THE DETERMINANT OF THE MATRIX

C++ PROGRAM Inputting  NINE INPUTS AND TREATS THE INPUTS  AS COMPONENTS OF THREE DIMENSIONAL MATRIX AND CALCULATES THE DETERMINANT OF THE MATRIX



#include <stdio.h>
#include <conio.h>      // HEADER FILES
#include <iostream.h>

void main()
     {
     clrscr();
     int matrix[4][4];        // DECLARATION OF ARRAY AND VARIABLES.
     int count,count1,result;
     int x,y;

     for (count1=1;count1<=3;count1++)
                     // NESTED FOR LOOPS TO TAKE INPUTS
                     // FROM THE USER.
    {

      for (count=1;count<=3;count++)
        {
         clrscr();
         gotoxy(21,13);
         cout << "PLEASE ENTER A INTEGER : ";
         cin >> matrix[count][count1]; // INPUT IS STORED IN DIFFERENT
                           // ADDRESSES OF THE ARRAY.

         }

      }

     // THE FOLLOWING STEPS PERFORM DIFFERENT CALCULATIONS TO CALCULATE THE
     // DETERMINANT

     count  = matrix[1][1]*((matrix[2][2]*matrix[3][3])-(matrix[3][2]*matrix[2][3]));
     count1 = matrix[2][2]*((matrix[1][2]*matrix[3][3])-(matrix[3][2]*matrix[1][3]));
     result = matrix[3][3]*((matrix[1][2]*matrix[2][3])-(matrix[2][2]*matrix[1][3]));


     result = count - count1+result;

     gotoxy(21,15);
     cout << "THE DETERMINANT OF MATRIX IS :"<<result; // SHOWS THE DETERMINANT

     getch();

   }  // END OF FUNCTION 

0 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More