Loading…
OS · First scripts · Program 19 · In the record
Write a program in shell script to swap the values without using the third variables
1#!/bin/bash2 3echo "Enter the first number (a):"4read a5 6echo "Enter the second number (b):"7read b8 9echo "Before swapping: a = $a, b = $b"10 11a=$((a + b))12b=$((a - b))13a=$((a - b))14 15echo "After swapping: a = $a, b = $b"10 ⏎ 20Enter the first number (a): 10 Enter the second number (b): 20 Before swapping: a = 10, b = 20 After swapping: a = 20, b = 10
Run program 19 in your browser
bash · just-bash. Change the code or the input, run it, break it, and see what happens.