-
Notifications
You must be signed in to change notification settings - Fork 2
/
Arrays4.c
33 lines (32 loc) · 830 Bytes
/
Arrays4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<stdio.h>
/* This is a dumi program to revise how to work with two dimenzional arrays and functions*/
void read_matrix(int arr[10][10],int r);
void display_matrix(int arr[10][10],int r);
void main(){
int arr[10][10];
int r;
printf("Enter the number of rows and columns in the matrix");
scanf("%d",&r);
read_matrix(arr,r);
display_matrix(arr,r);
}
void read_matrix(int arr[10][10], int r){
for(int i=0;i<r;i++){
for(int j=0;j<r;j++){
if(i>j)
arr[i][j] = 1;
else if(i<j)
arr[i][j] = -1;
else
arr[i][j] = 0;
}
}
}
void display_matrix(int arr[10][10],int r){
for(int i=0;i<r;i++){
for(int j=0;j<r;j++){
printf("%d ",arr[i][j]);
}
printf("\n");
}
}