Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 09-05-2009
Member
 
Join Date: Apr 2009
Posts: 29
Calculating Matrix Determinant in C

Enter a 2x2 matrix of integers, calculate and display the determinant.
Tables with more than two dimensions: Proceed in the same way by adding elements of design.That restores my C code but I don't know what is the problem in the code.
Code:
 # include <stdio.h> 
  # include <conio.h> 

  int determinant (int m [1] [1]) 
  ( 
   return ((m [0] [0] * m [1] [1]) - (m [1] [0] * m [0] [1])); 
  ) 
  void main () 
  ( 
      int M [1] [1], i, j; 
    
    
      for (i = 0; i <= 1; i + +) 
         for (j = 0 j <= 1 j + +) 
         ( 
               printf ( "Donez the value of M [% d] [% d]:", i + 1, j + 1); 
               scanf ( "% d", & M [i] [j]); 
         ) 
      printf ( "and determine the% d", determinant (M)); 
      getch (); 
      return 0; 
  )
Reply With Quote
  #2  
Old 09-05-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Calculating Matrix Determinant in C

Debug :

Code:
  E: \ l Angaga C \ a \ main.c | 13 | warning: return type of 'main' is not `int '| 
  E: \ C \ a \ main.c | | In function `main ': | 
  E: \ l Angaga C \ a \ main.c | 25 | warning: `return 'with a value, in function returning void |
0 errors with 2 warnings
Reply With Quote
  #3  
Old 09-05-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Calculating Matrix Determinant in C

For additional dimensions, we can easily do so by recursion (through the development of row or column), although this is not really optimal.
Reply With Quote
  #4  
Old 09-05-2009
Member
 
Join Date: Apr 2009
Posts: 29
Re: Calculating Matrix Determinant in C

Code:
 int main (void);

and warnings disappears!

in the running it gives:

Code:
 Donez the value of M [1] [1]: 1 
  Donez the value of M [1] [2]: 2 
  Donez the value of M [2] [1]: 3 
  Donez the value of M [2] [2]: 4 
  and -5 determine the
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Calculating Matrix Determinant in C"
Thread Thread Starter Forum Replies Last Post
New Matrix Movie (Matrix ReEntered) Vicious Off Topic Chat 8 08-02-2011 08:24 PM
Any fastest way to compute 3x3 Matrix inverse and Matrix multiplication? Logan.B Software Development 4 25-09-2010 05:11 PM
Calculating Age in java Miles Runner Software Development 5 03-02-2010 01:54 AM
Calculating identity matrix with static method in C Measurer Software Development 5 29-01-2010 06:47 PM
Calculating the sum of two polynomials Liquid Shadow Software Development 3 30-11-2009 12:12 PM


All times are GMT +5.5. The time now is 07:28 PM.