Horje
Program to Find Swap Numbers Using Temporary Variable Code Example
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();
  }
}
Program to Find Swap Numbers Using Temporary Variable
#include<stdio.h>

int main() {
   int x, y, temp;
   printf("Enter the value of x and y: ");
   scanf("%d %d", &x, &y);
   printf("Before swapping x=%d, y=%d ", x, y);
    
   /*Swapping logic */   temp = x;
   x = y;
   y = temp;
   printf("After swapping x=%d, b=%d", x, y);
   return 0; 
}
Program Output:




C

Related
georgia institute of technology Code Example georgia institute of technology Code Example
amazon kinesis disaster recovery Code Example amazon kinesis disaster recovery Code Example
retoure a la ligne C Code Example retoure a la ligne C Code Example
fina students name by using html backend database Code Example fina students name by using html backend database Code Example
Armstrong in c Code Example Armstrong in c Code Example

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