Friends I am having little problem in passing arrays through function, hope you will help me. Actually I have to make a program to calculate the row sum and column sum of an 2D array, and using call by reference functions. Please tell the correct syntax of passing a 2D array through a function by reference. Below is the code. Please answer fast tomorrow is my exam.
#include< iostream.h>
#include< conio.h>
#include< stdio.h>
void row_sum(int *);//Syntax Please//
void column_sum(int *);//Syntax Please//
main()
{
int a[10][10],i,rsum,csum,r,c,j,opt;
cout<<"Enter the number of rows.";
cin>>r;
cout<<"Enter the number of columns";
cin>>c;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
cin>>a[i][j]; //Input in an array
}
}
getch();
cout<<"(1) Row Sum.\n(2) Column Sum.";
cin>>opt;
switch(opt)
{
case 1:
row_sum(&a[10][10]);//Syntax Please//
break;
case 2:
column_sum(&a[10][10]);//Syntax Please//
break;
}
getch();
}
void row_sum(int *a[10][10])//Syntax Please//
{
//Example// cout<<a[2][3];//Syntax Please//
//---segment for calculating row sum---//
}
void column_sum(int *a[10][10])//Syntax Please//
{
//Example// cout<<a[2][3];//Syntax Please//
//---segment for calculating column sum---//
}