Consider, for example, a C program below,

/* * actual_formal_arg.c -- program hinges on relationship between actual and * formal arguments */ #include <stdio.h> void even_odd(int); int main(void) { int num, what; printf("\nProgram determines a given integer is EVEN or ODD\n\n"); printf("Enter an integer number: (q to quit)\n"); while (what = scanf("%d", &num) == 1) { even_odd(num); /* integer num here is distinct from integer num in even_odd() */ printf("Enter another integer: (q to quit)\n"); } printf("Thank you!\n"); return 0; } /* num declared here is private to even_odd() */ void even_odd(int num) { if (num % 2 == 0) printf("%d is EVEN Number!\n", num); else printf("%d is ODD Number!\n", num); return; }

Below is output of the above program, for several test integers,

Program determines a given integer is EVEN or ODD Enter an integer number: (q to quit) 1009 1009 is ODD Number! Enter another integer: (q to quit) 34 34 is EVEN Number! Enter another integer: (q to quit) 12 12 is EVEN Number! Enter another integer: (q to quit) 1 1 is ODD Number! Enter another integer: (q to quit) 2 2 is EVEN Number! Enter another integer: (q to quit) q Thank you!

Now, we unravel difference between actual and formal arguments. Integer variable num in ‘main()’ is local to ‘main()’ and is distinct from integer variable num, being private to ‘even_odd()’ even they have same names. Therefore, **there’s no conflict with same names when used in different functions.** When function

even_odd(num);

in ‘main()’ is called, **actual value of num, here for ex. 1009, is placed in temporary storage area called stack, from where this value is copied to the argument num of called function.**

void even_odd(int num) { }

**Function ‘even_odd()’ performs on the copied value of original value of num. Therefore, argument num private to even_odd() function is called formal argument or formal parameter and argument num local to main() function is called actual argument.**

**Sanfoundry Global Education & Learning Series – 1000 C Tutorials.**

**Related Posts:**

- Apply for C Internship
- Watch Advanced C Programming Videos
- Practice BCA MCQs
- Check Computer Science Books
- Practice Computer Science MCQs