Skip to main content

SWAP Two Values without using temporary variable

/**
    Program Name: Swap Two Numbers

    Description: This Program swaps two number, using XOR

    Author:  Tauqirul Haque
      
*/

#include <stdio.h>
#include <conio.h>

int main()
{
    int firstNumber, secondNumber;
  
    printf("Enter The First Number :  ");
    scanf("%d",&firstNumber);
  
    printf("\nEnter The Second Number :  ");
    scanf("%d",&secondNumber);
  
    printf("\n\nNumbers Before Swapping :  %d  <-> %d \n",firstNumber, secondNumber);
  
    firstNumber = firstNumber^secondNumber;
    secondNumber = firstNumber^secondNumber;
    firstNumber = firstNumber^secondNumber;
  
    printf("\nNumbers After Swapping :   %d  <->  %d \n",firstNumber, secondNumber);
  
}

Comments

Popular posts from this blog

SIMPLE QUEUE

/**     Program Name: SIMPLE QUEUE     Description: This program is for Implementing Simple QUEUE     Author:  Tauqirul Haque         */ #define SIZE 3 int front = -1; int rear = -1; int queue[SIZE]; void deleteElement(); void insertElement(); void displayElement(); void main() {     int ch;     while(ch !=4)     {         printf("\n\t\t1. Insert into queue..\n");         printf("\t\t2. Delete From Queue...\n");         printf("\t\t3. Diplay Queue...\n");         printf("\t\t4. Exit Program ...\n");                 printf("Enter Your Choice #  ");         scanf("%d",&ch);         ...

Getting Linux CD Free to Your Door-Steps

Getting a UBUNTU Linux CD at your doorstep is very easy, and this all comes to you at NO-COST.. no need to pay a single cent. All you need to do is to follows these given steps .... Step 1: Log on to https:/ /shipit. ubuntu. com Step 2: Click on the Required CD you want .. (i.e. Desktop or Server Version) Step 3: Log into your account or create a new one ( if you don't have one) Step 4: Fill in your details with proper Address and done .... The CD will arrive you with 1-1.5 month ... ........... Happy Linux .............

CIRCULAR QUEUE

/**     Program Name: Circular Queue     Description: Circular Queue using Array     Author:  Tauqirul Haque         */ int front = -1;  //This is the Initial Condition int rear = -1; #define SIZE 5 int queue[SIZE]; void deleteElement(); void insertElement(); void displayElement(); void main() {     int ch;     while(ch !=4)     {         printf("\n\t\t1. Insert into queue..\n");         printf("\t\t2. Delete From Queue...\n");         printf("\t\t3. Diplay Queue...\n");         printf("\t\t4. Exit Program ...\n");                 printf("Enter Your Choice #  ");         scanf("%d",&ch);     ...