"swap 2 integers without using temporary variable" Code Answer's
You're definitely familiar with the best coding language C that developers use to develop their projects and they get all their queries like "swap 2 integers without using temporary variable" answered properly. Developers are finding an appropriate answer about swap 2 integers without using temporary variable related to the C coding language. By visiting this online portal developers get answers concerning C codes question like swap 2 integers without using temporary variable. Enter your desired code related query in the search bar and get every piece of information about C code related question on swap 2 integers without using temporary variable.
swap without using third variable
// SWAPPING WITHOUT USING THIRD VARIABLE
#include<stdio.h>
int main()
{
int a=10, b=20;
printf("Before swap a=%d b=%d",a,b);
a=a+b;//a=30 (10+20)
b=a-b;//b=10 (30-20)
a=a-b;//a=20 (30-10)
printf("\nAfter swap a=%d b=%d",a,b);
return 0;
}
Source: www.javatpoint.com
swap 2 integers without using temporary variable
using System;
class MainClass {
public static void Main (string[] args) {
int num1 = int.Parse(Console.ReadLine());
int num2 = int.Parse(Console.ReadLine());
num1 = num1 + num2;
num2 = num1 - num2;
num1 = num1 - num2;
Console.WriteLine("After swapping: num1 = "+ num1 + ", num2 = " + num2);
Console.ReadLine();
}
}
All those coders who are working on the C based application and are stuck on swap 2 integers without using temporary variable can get a collection of related answers to their query. Programmers need to enter their query on swap 2 integers without using temporary variable related to C code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about swap 2 integers without using temporary variable for the programmers working on C code while coding their module. Coders are also allowed to rectify already present answers of swap 2 integers without using temporary variable while working on the C language code. Developers can add up suggestions if they deem fit any other answer relating to "swap 2 integers without using temporary variable". Visit this developer's friendly online web community, CodeProZone, and get your queries like swap 2 integers without using temporary variable resolved professionally and stay updated to the latest C updates.