Search
 
SCRIPT & CODE EXAMPLE
 

C

swapping of two numbers in c without temporary variable

#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);      
}   
Comment

swapping of two numbers without using third variable in c

#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);
}
Comment

swapping two numbers in c

//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;
Comment

c program for swapping of two numbers using temporary variable

#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);
}
Comment

c program for swapping of two numbers

// 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;
}
Comment

PREVIOUS NEXT
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 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =