#include<stdio.h>
#include<conio.h>
int sum(int *ptr,const int row,const int col);
void main()
{
int a[][3]={1,2,3,4,5,6,7,8,9};
int *ptr;
clrscr();
ptr=&a[0][0];
printf("%d",sum(ptr,3,3));
getch();
}
int sum(int *ptr,const int row,const int col)
{
int s=0;
for(int i=0;i<row*col;i++)
{
s=s+*(ptr+i);
}
return s;
}
NOTE: program will sum all the elements of array.
No comments:
Post a Comment