Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int n,m;
- int i,j;
- int mat[50][50];
- int sum[50];
- int prod[50];
- int s[50];
- int p[50];
- /*write a program that fills a matrix of integers
- M of size ( n*m) and then calculates the sum and product
- of each column and puts it in respective arrays S and P*/
- printf("donner les dimension :\t");
- scanf ("%d %d",&n,&m);
- for (i=0;i<n;i++)
- {
- for (j=0;j<m;j++)
- {
- printf("mat[%d][%d] : ",i,j);
- scanf("%d",&mat[i][j]);
- }
- }
- printf("**Matrice donnée**:\n");
- for (i=0;i<n;i++)
- {
- for (j=0;j<m;j++){
- printf("%d ",mat[i][j]);
- }
- printf("\n");
- }
- printf("Sum Array: ");
- for (j=0;j<m;j++)
- {
- sum[j]=0;
- for (i=0;i<n;i++)
- {
- sum[j]=sum[j]+mat[i][j];
- }
- printf("%d\t", sum[j] );
- }
- }
Add Comment
Please, Sign In to add comment