fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #define SIZE 3 //defining the size of the matrix (3x3)
  4.  
  5. //prototyping the functions used to calculate the inverse of the matrix
  6. void readMatrix(double a[SIZE][SIZE]);
  7. void printMatrix(double a[SIZE][SIZE]);
  8.  
  9.  
  10. main()
  11. {
  12. double a[SIZE][SIZE];
  13. int i,j;
  14.  
  15.  
  16. printf("Enter the values for the matrix:\n");
  17. readMatrix(a);
  18. printf("Your Matrix:\n");
  19. printMatrix(a);
  20.  
  21. return 0;
  22. }
  23.  
  24.  
  25. //function 1
  26. //letting the user to enter a matrix
  27. void readMatrix(double a[SIZE][SIZE]){
  28.  
  29.  
  30. int i,j;
  31.  
  32. for(i = 0; i < SIZE; i++){
  33. for(j = 0; j < SIZE; j++){
  34. scanf("%lf", &a[i][j]);
  35.  
  36. }
  37. }
  38. }
  39.  
  40. //function 2
  41. //outputing the given matrix
  42. void printMatrix(double a[SIZE][SIZE]){
  43.  
  44. int i,j;
  45.  
  46. for(i = 0; i < SIZE; i++){
  47. for(j = 0; j < SIZE; j++){
  48. printf("Your matrix is: %lf", a[i][j]);
  49. }
  50. }
  51. }
Success #stdin #stdout 0s 9432KB
stdin
1 2 3 4 5 6 7 8 9
stdout
Enter the values for the matrix:
Your Matrix:
Your matrix is: 1.000000Your matrix is: 2.000000Your matrix is: 3.000000Your matrix is: 4.000000Your matrix is: 5.000000Your matrix is: 6.000000Your matrix is: 7.000000Your matrix is: 8.000000Your matrix is: 9.000000