0% found this document useful (0 votes)
15 views

Call by Value Program

This C program demonstrates call by value by passing the values of two integers, a and b, into a swap function. The swap function swaps the values of the parameters a and b by using a temporary variable, but this does not affect the original values of a and b in main, since call by value was used. The original values of a and b in main are printed as 100 and 200.

Uploaded by

Vivek CHOWDARY
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Call by Value Program

This C program demonstrates call by value by passing the values of two integers, a and b, into a swap function. The swap function swaps the values of the parameters a and b by using a temporary variable, but this does not affect the original values of a and b in main, since call by value was used. The original values of a and b in main are printed as 100 and 200.

Uploaded by

Vivek CHOWDARY
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Call by value Program:-

#include<stdio.h>

void swap(int a, int b)

int temp;

temp=a;

a=b;

b=temp;

void main()

int a=100, b=200;

swap(a, b); // passing value to function

printf("\nValue of a: %d",a);

printf("\nValue of b: %d",b);

}
Output:-

You might also like