filmov
tv
C program to swap two numbers without using a temporary variable // C programming

Показать описание
Hi ,
in this program we learn how to write a C program to swap two integer numbers without using temporary variable .
Given two integer numbers "a" and "b" and we have to swap their values without using any temporary variable.
Example:
Input: a=10, b=20
Output: a=20, b=10
a = a+b; //step 1
b = a-b; //step 2
a = a-b; //step 3
# interview asked questions in C
# C interview questions
# information technology interview questions
# Computer engineering interview questions
in this program we learn how to write a C program to swap two integer numbers without using temporary variable .
Given two integer numbers "a" and "b" and we have to swap their values without using any temporary variable.
Example:
Input: a=10, b=20
Output: a=20, b=10
a = a+b; //step 1
b = a-b; //step 2
a = a-b; //step 3
# interview asked questions in C
# C interview questions
# information technology interview questions
# Computer engineering interview questions