Horje
swap without using third variable Code Example
swapping of two numbers without using third variable in shell script
#!/bin/bash
echo "enter first number"
read a
echo "enter second number"
read b
echo "a before swapping is $a and b is $b"
#swapping
a=$((a+b))
b=$((a - b))
a=$((a-b))
echo "a after swapping is  $a and b is $b"
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;  
}   
how to swap 2 numbers without 3rd variable
int a = 3;
int b = 5;
a = b*a;
b = a/b
a = a/b
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 third variable
var a=window.prompt('enter a number')var b=window.prompt('enter a number')var a=a+b;var b=a-b;var a=a-b;console.log ("value of a is",a);console.log('value of b is',b);




C

Related
arduino digital read Code Example arduino digital read Code Example
differnce between spooling and buffering Code Example differnce between spooling and buffering Code Example
C number of digits in integer Code Example C number of digits in integer Code Example
How to make a multiline string in C Code Example How to make a multiline string in C Code Example
create cron task Code Example create cron task Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8