Results 1 to 4 of 4

Thread: Calculating Matrix Determinant in C

  1. #1
    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; 
      )

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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

  3. #3
    Join Date
    May 2008
    Posts
    2,297

    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.

  4. #4
    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

Similar Threads

  1. New Matrix Movie (Matrix ReEntered)
    By Vicious in forum Off Topic Chat
    Replies: 8
    Last Post: 08-02-2011, 08:24 PM
  2. Replies: 4
    Last Post: 25-09-2010, 05:11 PM
  3. Calculating Age in java
    By Miles Runner in forum Software Development
    Replies: 5
    Last Post: 03-02-2010, 01:54 AM
  4. Calculating identity matrix with static method in C
    By Measurer in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 06:47 PM
  5. Calculating the sum of two polynomials
    By Liquid Shadow in forum Software Development
    Replies: 3
    Last Post: 30-11-2009, 12:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,728,410.95457 seconds with 16 queries