Some questions on calling a function
Consider our example from the notes:
#include <stdio.h>
void PrintTwo(int Val1, int Val2) {
/* Print 2 ints on a line */
printf("%d %d \n",Val1,Val2);
}
int Larger(int IVal1,int IVal2) {
/*Return the larger of 2 ints*/
if (IVal1>IVal2) return IVal1;
return IVal2;
}
void main() {
int X;
X = -100;
PrintTwo(X,Larger(X,200));
}
Plain text to compile and run.
- Would it be legal to write Larger(4,6); as a statement on its own?
- Would it be legal to write X = Larger(X,200);
- What would the output be when running the example? Try compiling and
running it to check.
Answers to these questions.
Next - Function prototypes.