"Swap two numbers without using a third variable ( All possible ways )." Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "Swap two numbers without using a third variable ( All possible ways )." answered properly. Developers are finding an appropriate answer about Swap two numbers without using a third variable ( All possible ways ). related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like Swap two numbers without using a third variable ( All possible ways ).. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on Swap two numbers without using a third variable ( All possible ways )..
Write a program to show swap of two numbers 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;
}
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();
}
}
Swap two numbers without using a third variable ( All possible ways ).
Swaping two numbers without using temp variable
All those coders who are working on the Whatever based application and are stuck on Swap two numbers without using a third variable ( All possible ways ). can get a collection of related answers to their query. Programmers need to enter their query on Swap two numbers without using a third variable ( All possible ways ). related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about Swap two numbers without using a third variable ( All possible ways ). for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of Swap two numbers without using a third variable ( All possible ways ). while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "Swap two numbers without using a third variable ( All possible ways ).". Visit this developer's friendly online web community, CodeProZone, and get your queries like Swap two numbers without using a third variable ( All possible ways ). resolved professionally and stay updated to the latest Whatever updates.