#include<stdio.h>
void main()
{
int a=10, b=20;
printf("Before swap a=%d b=%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("
After swap a=%d b=%d",a,b);
}
#include<stdio.h>
void main()
{
int x = 10, y = 20;
printf("Before swap x=%d y=%d",x,y);
x=x+y;
y=x-y;
x=x-y;
printf("
After swap x=%d y=%d",x,y);
}
//Author: Subodh
//! Swap two number using XOR operation
cout << "Before, n1 = " << num1 << ", n2 = " << num2 << endl;
num1 = num1 ^ num2, num2 = num1 ^ num2, num1 = num1 ^ num2;
cout << "After, n1 = " << num1 << ", n2 = " << num2 << endl;
#include <stdio.h>
int main()
{
int a, b, temp;
printf("enter the values of a and b:
");
scanf("%d%d", &a, &b );
printf("current values are:
a=%d
b=%d
", a, b);
temp=a;
a=b;
b=temp;
printf("After swapping:
a=%d
b=%d
", a, b);
}
// Overcomplicating things lol. Try this
#include <stdio.h>
int main()
{
int x, y;
printf("Enter Value of x ");
scanf("%d", &x);
printf("
Enter Value of y ");
scanf("%d", &y);
int temp = x;
x = y;
y = temp;
printf("
After Swapping: x = %d, y = %d", x, y);
return 0;
}
Code Example |
---|
C :: terminal size in c |
C :: c distance between 2 points |
C :: c check if file exists |
C :: get pid c |
C :: c remove last character from a string |
C :: golang loop through array |
C :: lewis hamilton |
C :: octave dot operator |
C :: react-textfit |
C :: if statement shorthand c |
C :: c boolean |
C :: c printf to string |
C :: Prime Number Check Program in C |
C :: how to find sum of two nums |
C :: print 0 1 2 3 4 in c |
C :: how to print a file c |
C :: check if the c code is a palindrome |
C :: puts without newline c |
C :: string input c |
C :: how to modulo in c without use the operator |
C :: limit axis in one direction plt |
C :: how to make sure input is integer c |
C :: isspace |
C :: print variable adress c |
C :: server client tcp in C |
C :: quick sort c |
C :: how to input n space separated integers in c |
C :: pid of a process in c |
C :: implement crc using c language |
C :: Program to print all palindromes in a given range |