Write a program that declares a 35 array of int and initiali

Write a program that declares a 3×5 array of int and initializes it to some values of your choice. - Write a function to do the displaying and - a second function to do the doubling.

Have the functions take the array name and the number of rows as arguments.

#include <stdio.h>

#include <stdlib.h>

#define ROWS 3

#define COLS 5

void DisplyArray(int a[][COLS], int rowSize, int colSize)

{

int i, j;

for (i=0 ; ; ){

for (j = 0; ; )

printf(\"%d\\t\",a[i][j]);

printf(\"\ \");

}

}

void DoubleArray(int (*a)[COLS], int rowSize, int colSize)

{

int i, j;

}

int main()

{

int a[][COLS]={{13, 24, 77, 78, 19},

{20, 18, 36, 48, 87},

{87, 43, 29, 12, 34}};

printf(\"The Original Array\ \");

DisplyArray( );

DoubleArray( );

printf(\"The Array after Doubleing\ \");

DisplyArray( );

  

return 0;

}

Solution

#include <stdio.h>

#include <stdlib.h>

#define ROWS 3

#define COLS 5

void DisplyArray(int a[][COLS], int rowSize, int colSize)

{

   int i, j;

   for (i=0 ;i< rowSize ; i++ ){  

      for (j = 0; j < colSize; ++j )

         printf(\"%d\\t\",a[i][j]);

      printf(\"\ \");

   }

}

void DoubleArray(int (*a)[COLS], int rowSize, int colSize)

{

   int i, j;
   for(i=0;i<rowSize;++i)
     {
       for(j=0;j<colSize;j++)
   a[i][j]=2*a[i][j];
     }

}

int main()

{

   int a[][COLS]={{13, 24, 77, 78, 19},

             {20, 18, 36, 48, 87},

             {87, 43, 29, 12, 34}};

   printf(\"The Original Array\ \");

   DisplyArray(a,ROWS, COLS);

   DoubleArray(a, ROWS, COLS);

   printf(\"The Array after Doubleing\ \");

   DisplyArray(a, ROWS, COLS);

  

   return 0;

}

Write a program that declares a 3×5 array of int and initializes it to some values of your choice. - Write a function to do the displaying and - a second functi
Write a program that declares a 3×5 array of int and initializes it to some values of your choice. - Write a function to do the displaying and - a second functi
Write a program that declares a 3×5 array of int and initializes it to some values of your choice. - Write a function to do the displaying and - a second functi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site