google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to swap two numbers using call by reference - 2nd puc computer science

Write a c program to swap two numbers using call by reference

 Write ac program to perform swapping of two number using call by reference,swap two numbers using call by address in c 

Write a c program to swap two numbers using call by reference

#include<stdio.h>

#include<conio.h>

void main()

{

void swap(int *, int *);

int a=10,b=20;

printf(“Entered numbers are a=%d and b=%d\n”,a,b);

swap(&a,&b);

printf(“Entered numbers after swapping are a=%d and b=%d”,a,b);

getch();

}

void swap(int *x, int *y)

{

int temp;

temp=*x;

*x=*y;

*y=temp;

}

Output:

Entered numbers are a=10 and b=20                                              

Entered numbers after swapping are a=20 and b=10  

Write a c program to swap two numbers using call by reference Write a c program to swap two numbers using call by reference Reviewed by Vision Academy on December 14, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.