Download presentation
Presentation is loading. Please wait.
Published byShonda Hunter Modified over 9 years ago
1
Multidimensional Arrays As Parameter void fun ( int matrix [] [10] ) {…} void main ( ) { int mat[5][10]; … fun(mat); } void fun (float *mat_ptr, int num_rows, int num_cols); *(mat_ptr + (row * num_cols) + col) = x; #define mat_ptr(r,c) (*(mat_ptr + (r * num_cols) + c)) mat_ptr(row,col) = x;
2
int i=3; void fun(int a, int b) { i=b; } void main() { int list[10]; list[i] = 5; fun(i,list[i]); } pass-by-value-result i and a are not aliases global i in fun change from 3 to 5 when copy back, it is set back to 3 pass-by-reference i and a are aliases i remains 5 Examples of parameter passing
3
Overloaded Subprograms void fun(float b) {b = 3.14;} void fun(); … float x; fun(); fun(x); void fun(float b = 0.0); void fun(); … fun();
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.