Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX 10
- int main()
- {
- int dimension, i, j, sum;
- typedef int TwoDArray[MAX][MAX];
- TwoDArray *array;
- printf("Enter the dimension of the array: ");
- scanf("%d", &dimension);
- array = malloc(sizeof(int) * (dimension * 2));
- for (i = sum = 0; i < dimension; i++)
- for (j = 0; j < dimension; j++)
- {
- scanf("%d", &(*array)[i][j]);
- sum += (*array)[i][j];
- }
- for (printf("The array:\n\n"), i = 0; i < dimension; i++, printf("\n"))
- for (j = 0; j < dimension; j++)
- printf("%d ", (*array)[i][j]);
- printf("\nSum of all elements: %d", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement