User Defined Functions In C Language
User Defined Functions
Functions defined by us are known as User Defined Functions.
main( ) function is also user defined function because the definition of main( ) is defined by us.
E.g.
int power(int, int);
main( )
{
');
var s = document.createElement('script');
s.type = 'text/javascript'; s.async = true;
s.src = 'https://ad.admitad.com/shuffle/289c251618/'+subid_block+'?inject_to='+injectTo;
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})();
int n, p, ans;
printf(“Enter number and its power”);
scanf(“%d%d”, &n,&p);
ans = power(n,p);
printf(“%d”,ans);
getch( );
}
int power(int n, int p)
{
in ans=1, i;
for(i=1;i<=p;i++)
{
ans = ans * n;
}
');
var s = document.createElement('script');
s.type = 'text/javascript'; s.async = true;
s.src = 'https://ad.admitad.com/shuffle/289c251618/'+subid_block+'?inject_to='+injectTo;
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
})();
return(ans);
}
Function whose argument is a two dim array
void mat_sum(int m1[][10], int r1, int c1, int m2[][10], int r2, int c2, int m3[][10])
{
int i,j;
if(r1 != c1 && r2 !=c2)
{
printf(“Can’t sum”);
exit( );
}
for(i=0;j<r1;i++)
for(j=0;j<c1;j++)
m3[i][j] = m1[i][j] + m2[i][j];
}
The above function can be called from main( )as mat_sum(m1,r1,c1,m2,r2,c2,m3);