# Write a function Exchange to interchange the values of two variables

0 like 0 dislike
3.3k views

Write a function Exchange to interchange the values of two variables, say x and y using C programming

### For Indian Students- INR 360/- || For International Students- \$9.99/-

S.No.

Course Name

Coupon

1.

Tensorflow 2 & Keras:Deep Learning & Artificial Intelligence || Labeled as Highest Rated Course by Udemy

Apply Coupon

2.

Complete Machine Learning & Data Science with Python| ML A-Z Apply Coupon

3.

Complete Python Programming from scratch | Python Projects Apply Coupon

0 like 0 dislike
by Goeduhub's Expert (7.1k points)
edited

Exchange of Two Numbers Using Function

In this program we are going to implement exchange of two numbers using function in C programming.

To learn basics of function in C programming Click Here.

Example :

 #include#include//Declaration of exchange functionvoid exchange(int x,int y);void main(){int x,y;clrscr();//Taking two numbers from userprintf("\nEnter two numbers:");scanf("%d%d",&x,&y);printf("\nBefore Exchange x = %d and y = %d",x,y);//calling exchange functionexchange(x,y);getch();}//Definition of exchange functionvoid exchange(int x,int y){int z;z=x;x=y;y=z;printf("\nAfter Exchange x = %d and y = %d",x,y);}

Output :