0
what is the use of function call here?
#include <stdio.h> int max(int [],int); int main() { int a[4]; int r,i; printf("enter the numbers"); for(i=0;i<4;i++) { scanf("%d",&a[i]); } r=max(a,4); printf("%d",r); } int max(int b[],int c) { int max,i; max=b[0]; for(i=1;i<c;i++) { if(max<b[i]) { max=b[i]; } } return max; }
2 Respostas
+ 1
Functions are little sub programs that do one specific thing.
It helps, because you can write them once, test if they work, and if they do, you don't even have to think about it, you just use it as a tool.
Take printf - that's also a function. Who knows what it actually does? You don't even have to know, you just use it, which is relatively simple.
0
The function call made in your code helps you get the maximum of the 4 numbers from the array.
If you don't make a function call then you wouldn't receive anything and nothing would be stored in the variable "r".
Edit: you could also write that program without using functions than calling a function wouldn't have been necessary.