#include <stdio.h>
// Define a function that takes an integer as an argument and increments it
void increment(int x) {
x++;
}
int main(void) {
// Declare an integer and print its value
int num = 5;
printf("Original value: %d\n", num);
// Call the increment function
increment(num);
// Print the value of the integer again
printf("After increment: %d\n", num);
return 0;
}
This program defines a function called increment that takes an integer as an argument and increments it. When the increment function is called from the main function, it receives a copy of the value of the num variable as its argument. This means that any changes made to the argument within the function have no effect on the original variable.
Here is an example of the output of this program:
Original value: 5
After increment: 5

0 Comments