Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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:
Source by www.w3schools.in #
 
PREVIOUS NEXT
Tagged: #Program #Find #Swap #Numbers #Using #Temporary #Variable
ADD COMMENT
Topic
Name
1+4 =