Answer:
In C:
#include <stdio.h>
#include <stdlib.h>
int main() {
int r,c;
printf("Row: "); scanf("%d", &r);
printf("Cols: "); scanf("%d", &c);
double *myarr = (int *)malloc(r * c * sizeof(int));
double inputs = 0.0;
for (int rww = 0; rww < r; rww++){
for (int ccl = 0; ccl < c; ccl++){
inputs= inputs+1.0;
*(myarr + rww*ccl + ccl) = inputs; }}
return 0;}
Step-by-step explanation:
This declares the rows and columns as integers
int r,c;
This gets the number of rows
printf("Row: "); scanf("%d", &r);
This gets the number of columns
printf("Cols: "); scanf("%d", &c);
This dynamically allocate space for array myart
double *myarr = (int *)malloc(r * c * sizeof(int));
This initializes the inputs to the array to 0.0
double inputs = 0.0;
This iterates through the array and initializes each element of the array by its index
for (int rww = 0; rww < r; rww++){
for (int ccl = 0; ccl < c; ccl++){
inputs= inputs+1.0;
*(myarr + rww*ccl + ccl) = inputs; }}