Arfizato

sumboy

May 19th, 2022 (edited)
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int n,m;
  6. int i,j;
  7. int mat[50][50];
  8. int sum[50];
  9. int prod[50];
  10. int s[50];
  11. int p[50];
  12. /*write a program that fills a matrix of integers
  13. M of size ( n*m) and then calculates the sum and product
  14. of each column and puts it in respective arrays S and P*/
  15.  
  16. printf("donner les dimension :\t");
  17. scanf ("%d %d",&n,&m);
  18.  
  19.  
  20. for (i=0;i<n;i++)
  21. {
  22.     for (j=0;j<m;j++)
  23. {
  24. printf("mat[%d][%d] : ",i,j);
  25. scanf("%d",&mat[i][j]);
  26. }
  27. }
  28.  
  29.  
  30. printf("**Matrice donnée**:\n");
  31. for (i=0;i<n;i++)
  32. {
  33. for (j=0;j<m;j++){
  34. printf("%d ",mat[i][j]);
  35. }
  36. printf("\n");
  37. }
  38. printf("Sum Array: ");
  39. for (j=0;j<m;j++)
  40. {
  41.     sum[j]=0;
  42.     for (i=0;i<n;i++)
  43.     {
  44.         sum[j]=sum[j]+mat[i][j];
  45.     }
  46.         printf("%d\t", sum[j] );
  47.  
  48.  
  49. }
  50.  
  51. }
  52.  
RAW Paste Data Copied