fork download
  1. //Finds something called the norm of a matrix
  2.  
  3. #include <stdio.h>
  4. #include <math.h>
  5.  
  6. int main()
  7. {
  8. int rows,columns;
  9. int i,j;
  10. int a[i][j];
  11. int norm=0,sqnorm=0;
  12.  
  13. printf("Enter the number of columns of ya matrix: ");
  14. scanf("%d",&rows);
  15.  
  16. printf("What about columns?\n");
  17. scanf("%d",&columns);
  18.  
  19. printf("Enter the elements of the matrix: ");
  20. for(i=0;i<rows;++i)
  21. {
  22. for(j=0;j<columns;++j)
  23. {
  24. scanf("%d",&a[i][j]);
  25. sqnorm+=a[i][j];
  26. }
  27. }
  28.  
  29. norm=pow(sqnorm,(1.0/2));
  30.  
  31. printf("The norm of this matrix is %d",norm);
  32. }
Success #stdin #stdout 0s 4544KB
stdin
Standard input is empty
stdout
Enter the number of columns of ya matrix: What about columns?
Enter the elements of the matrix: The norm of this matrix is 0