#include<stdio.h> #include<conio.h> #define MAX_ROWS 3 #define MAX_COLS 4 void print_square(int [ ] ); void main (void) { int row; int num [MAX_ROWS][MAX_COLS] = { {0,1,2,3}, {4,5,6,7}, {8,9,10,11} }; for(row=0; row<MAX_ROWS; row++) print_square(num[row]); } void print_square(int x[ ]) { int col; for (col = 0; col<MAX_COLS; col++) printf ("%dt", x[col] * x[col]); printf("n"); }
Output :
0 1 4 9 16 25 36 49 64 81 100 121
Explanation :
Note 1 :
- Wherever a macro name occurs in Program the Preprocessor Substitutes the code of the macro at that position.
- Whenever we use variable name instead of Macro it will throw error.
int row=3,column=3; int arr[row][column];
No comments:
Post a Comment