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 Programming to swap two variables

#include <stdio.h>

int main()
{
    int x = 20, y = 30, temp;
    temp = x;
    x = y;
    y = temp;
    printf("X = %d and Y = %d", x, y);
    
    return 0;
}
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 :: mongodb update 
C :: install tweaks ubuntu 
C :: how to modulo in c without use the operator 
C :: c string 
C :: how to scanf two dimensional array in c 
C :: array value from user c 
C :: callback c++ c 
C :: append to list in c 
C :: Convert mpg / mp4 to gif with ffmpeg 
C :: casting an int to a char in c 
C :: prime number c program 
C :: c read n bytes code 
C :: inputting an array in c 
C :: How to convert string to int without using library functions in c 
C :: selection sort algorithm in c 
C :: malloc basics 
C :: highest common factor algorithm in c 
C :: multiplication of matrix in c 
C :: pop and push shows black screen which needs to be pressed back flutter 
C :: imprimir matriz 
C :: argparse allow line break 
C :: how to print % in c 
C :: time include c 
C :: how to debug a segmentation fault in c 
C :: stack pop 
C :: predefined macros 
C :: Print mark-sheet of students 
C :: print char* address C 
C :: insertNode 
C :: call cuda kernel from c parameters 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =