Swapping Two Numbers in C Language
Swapping Two Numbers in C Language
Introduction
Swapping values of two variables is a common task. This program demonstrates swapping using a temporary variable.
Explanation
-
temp = a;
: Stores the value ofa
intemp
. -
a = b;
: Assigns the value ofb
toa
. -
b = temp;
: Assigns the original value ofa
tob
.
Comments
Post a Comment