Skip to content

Commit

Permalink
Update 2D Array.c
Browse files Browse the repository at this point in the history
  • Loading branch information
GloryTime6 authored Dec 28, 2021
1 parent ce6f5e5 commit 5a8dd9c
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Source Codes/2D Array.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,31 @@

#include <stdio.h>

void main()
int main()
{
int i, j, r, c;
printf("Enter the number of rows:\n");
int** array, i, j, r, c;
printf("Enter the number of rows:");
scanf("%d", &r);
printf("Enter the number of columns:\n");
printf("\n");
printf("Enter the number of columns:");
scanf("%d", &c);
int a[r][c];
printf("\n");
array = (int**)malloc(sizeof(int) * r);
for (i = 0; i < r; i++)
{
array[i] = (int*)malloc(sizeof(int) * c);
for (j = 0; j < c; j++)
{
printf("Enter the array element for %d, %d:\n", i, j);
scanf("%d", &a[i][j]);
scanf("%d", &array[i][j]);
}
}
printf("The array is:\n");
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
printf("%d\t", a[i][j]);
printf("%d\t", array[i][j]);
}
printf("\n");
}
Expand Down

1 comment on commit 5a8dd9c

@datreeio
Copy link

@datreeio datreeio bot commented on 5a8dd9c Dec 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All Rules (12 / 12) Passed

👑 Good job! this pull request is aligned with your organization's best practices!

👉 You can review your rules settings at smart policy management 👈

Please sign in to comment.