c
  1. c-program-to-swap-two-numbers

Program to Swap Two Numbers - (C Programs)

Example:

Input:

Enter value of a: 5
Enter value of b: 7

Output:

After swapping, value of a = 7
After swapping, value of b = 5

Explanation:

Swapping two numbers means exchanging the values of two variables with each other. In this program, we will take input two numbers from the user, swap their values, and then print them.

To swap two numbers, we will use a third variable. We will store the value of the first number in the third variable, then assign the value of the second number to the first number, and finally assign the value of the third variable to the second number.

Use:

This program can be used to swap the values of two variables.

Summary:

This program takes two numbers as input, swaps their values, and then prints the swapped values. It is a simple and effective way of exchanging the values of two variables.

Published on: