Write a c program which passes two dimension array to function






How to pass two dimensional array to a function in c

#include <stdio.h>
#define M 3
#define N 5
void fstore2D(int a[][N]);
void fretrieve2D(int a[][N]);
int main(){
  int a[M][N];
  printf("Input data in matrix (%d X %d)\n", M, N);
  fstore2D(a);
  fretrieve2D(a);
  return 0;
}
void fstore2D(int a[][N]){
    int i, j;
    for (i = 0; i < M; ++i){
    for (j = 0; j < N; ++j)
         scanf("%d", &a[i][j]);
    }
}
void fretrieve2D(int a[][N]){
   int i, j;
   for ( i = 0; i < M; ++i ){
       for ( j = 0; j < N; ++j)
            printf("%6d ", a[i][j]);
       printf("\n");
   }
}



Alogrithm:
**




10. Write a c program to add two numbers without using addition operator.
11. Write a c program to subtract two numbers without using subtraction operator.
15. Write a c program to solve quadratic equation.
18. Write a c program which passes structure to function.
28. Write a c program which takes password from user.
29. Write a scanf function in c which accept sentence from user.
30. Write a scanf function in c which accept paragraph from user.

No comments: