C Language Tutorials by Ghulam Murtaza Dahar - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

Output

Average age=27.08

Passing Multi-dimensional Arrays to Function

To pass two-dimensional array to a function as an argument, starting address of memory area reserved is passed as in one

dimensional array

Example to pass two-dimensional arrays to function

#include

void Function(int c[2][2]);

int main(){

int c[2][2],i,j;

printf("Enter 4 numbers:\n");

for(i=0;i<2;++i)

for(j=0;j<2;++j){

scanf("%d",&c[i][j]);

}

Function(c); /* passing multi-dimensional array to function */

return 0;

}

void Function(int c[2][2]){

/* Instead to above line, void Function(int c[][2]){ is also valid */

int i,j;

printf("Displaying:\n");

for(i=0;i<2;++i)

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

printf("%d\n",c[i][j]);

}

Find Your Next Great Read

Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.

Showing results for ""

Popular searches:

Romance Mystery & Thriller Self-Help Sci-Fi Business