SWAPPING OF TWO NUMBERS USING FUNCTIONS
Write a program in C to swap two numbers using function.
C programming: swapping two variables
Swapping two variables refers to mutually exchanging the values of the variables. Generally, this is done with the data in memory.
The simplest method to swap two variables is to use a third temporary variable :
define swap(a, b) temp := a a := b b := temp
Pictorial Presentation:

Sample Solution:
C Code:
Sample Output:
Function : swap two numbers using function : ------------------------------------------------ Input 1st number : 2 Input 2nd number : 4 Before swapping: n1 = 2, n2 = 4 After swapping: n1 = 4, n2 = 2
Flowchart:

Comments
Post a Comment