Question: functionExample.c #include #include #include #include int main () { void printHeading () { printf(Add/Sub demo: ); } int add (int a, int b) { int
functionExample.c
#include
int main () { void printHeading () { printf("Add/Sub demo: "); } int add (int a, int b) { int c; c = a + b; return c; } int sub (int a, int b) { return a - b; } int main () { int m, n; // no parameters printHeading (); //with direct values: printf ("5 + 6 = %d ", add(5,6)); //capturing the return m = sub (6,5); printf ("6 - 5 = %d ", m); //with variables m = 7; n = 8; printf ("%d + %d = %d ", m, n, add (m,n)); //return value into variable m = m + odd (m, n); //nested application: m = odd (m, add(m, sub(n,m))); printf ("m = %d ", m); } }
2.3a - mode the method main () in functionExample.c to the top of the file (but after the include's) so thatit's the first method. What is the compiler error generated?
2.3b - add function prototypes to the top of you functionExample.c file and verify this removes compiler messages when int main is moved to the top.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
