Tuesday, October 4, 2011

Traversing of array using Function - Pass array as parameter

/*                Traversing of array using Function                       */

#include<stdio.h>

#include<conio.h>

void disp(int *,int *,int,int);

 

void main()

{

  //clrscr();

  int a[3][3],b[3][3],c[3][3],i,j;

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

  {

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

                  {

                                  printf("enter your no");

                                  scanf("\n%d",&a[i][j],&b[i][j]);

                  }

  }

 

 add(a,3,3);

 

   }

void add(int *a,int *b,int m,int n)

{

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

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

                 {

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

                                 {

                 c[i][j]=a[i][j]+b[i][j];

                 }

                 }

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

                 {

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

                                 {

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

                 }

                 printf("\n");

                 }

  }

No comments :

Post a Comment