C Program

Actual Arguments And Formal Arguments

In C programming, actual arguments and formal arguments are terms used to describe how data is passed between functions. They refer to the variables or values that are used to provide input to and receive output from a function.

1. Actual Arguments (or Actual Parameters)

Actual arguments are the values or variables passed to a function when it is called. These values are provided by the calling code and are passed to the function when the function is invoked.

  • Actual arguments are supplied during the function call.
  • These arguments can be constant values, variables, or expressions.

Example of Actual Arguments:

#include <stdio.h>

void display(int x) {
printf("The value of x is: %d\n", x); // x is a formal argument in this function
}

int main() {
int num = 10;
display(num); // 'num' is the actual argument passed to the function
return 0;
}

2. Formal Arguments (or Formal Parameters)

Formal arguments are the variables defined in the function’s declaration or definition. These variables are used within the function to accept the values that are passed from the calling code.

  • Formal arguments act as placeholders for the actual arguments.
  • They are local to the function and hold the values passed to the function when the function is called.
void display(int x) {
printf("The value of x is: %d\n", x); // x is the formal argument in this function
}

Team Educate

About Author

Leave a comment

Your email address will not be published. Required fields are marked *

You may also like

C program to test whether a given identifier is valid or not
C Program

C Program to Test Whether a Given Identifier is Valid or Not

Rules for Valid Identifiers in C: The identifier must begin with a letter or an underscore (_). It cannot start
C program to test whether a given identifier is valid or not
C Program Compiler Design

C program to implement simple code generator

ALGORITHM:1. Start2. Get address code sequence.3. Determine current location of 3 using address (for 1st operand).4. If current location not