Question
I need this code changed from C++ to C programming. Everything works fine except its in C++ and should be in C, please help fixing
I need this code changed from C++ to C programming. Everything works fine except its in C++ and should be in C, please help fixing it:
#include
void PopulateArray2DUnique(int A[][COL], unsigned int rowsize,unsigned int colsize, int min , int max) { int i, j; for (i = 0; i < rowsize; i++) for (j = 0; j < colsize; j++) A[i][j] = min + rand() % (max - min+1); } void DisplayArray(int A[][COL] , unsigned int rowsize , unsigned int colsize) { int i, j; for (i = 0; i < rowsize; i++) { for (j = 0; j < colsize; j++) { cout< max) max = A[i][j]; } } return max; } int FindColumnSum(int A[][COL] , unsigned int rowsize , unsigned int colsize, unsigned int col_to_sum) { int Col_sum = 0; for (int i = 0; i < rowsize; i++) { // for (int j= col_to_sum; j < colsize; j++) { Col_sum += A[i][col_to_sum]; } } return Col_sum; } int Sort2DArray(int A[][COL] , unsigned int rowsize , unsigned int colsize, unsigned int Order) { int n = colsize; int temp[n * n]; int k = 0; if(Order == 1) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) temp[k++] = A[i][j]; sort(temp, temp + k); k = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) A[i][j] = temp[k++]; } else { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) temp[k++] = A[i][j]; sort(temp , temp + k , greater
void CopyArray2D(int A[][COL] ,int B[][COL] ,unsigned int rowsize , unsigned int colsize) { for (int i = 0; i < rowsize; i++) { for (int j = 0; j < colsize; j++) { B[i][j] = A[i][j]; } } } int CopyArray2DSpiral(int A[][COL] ,int B[][COL] ,unsigned int rowsize , unsigned int colsize) { int i, k = 0, l = 0; while (k < rowsize && l < colsize) { /* Print the first row from the remaining rows */ for (i = l; i < colsize; ++i) { B[l][colsize] = A[k][i]; } k++; /* Print the last column from the remaining columns */ for (i = k; i < rowsize; ++i) { B[k][rowsize]=A[i][colsize-1]; } colsize--; /* Print the last row from the remaining rows */ if ( k < rowsize) { for (i = colsize-1; i >= l; --i) { B[colsize-1][l] = A[rowsize-1][i]; } rowsize--; } /* Print the first column from the remaining columns */ if (l < colsize) { for (i = rowsize-1; i >= k; --i) { B[rowsize-1][k] = A[i][l]; } l++; } } }
int main() { int array[ROW][COL],ArrayB[ROW][COL]; PopulateArray2DUnique(array,ROW,COL,10,20); DisplayArray(array,ROW,COL); int largest = FindLargest(array,ROW,COL); cout<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started