CALL BY REFERENCE
INPUT
#include <stdio.h>
void reference(int *a, int *b)
{
int temp;
*a = *a + *b;
temp = *a;
temp = temp - *b;
*b = temp - *b;
}
int main()
{
int a, b;
printf("Enter the two numbers\n");
scanf("%d\n %d\n", &a, &b);
reference(&a, &b);
printf("The new value of a and b are %d and %d", a, b);
return 0;
}
OUTPUT
Enter the two numbers
4
3
The new value of a and b are 7 and 1
No comments:
Post a Comment