Ads

Thursday, May 28, 2020

Write a C program to swap two numbers without using a temporary variable

Write a C program to swap two numbers without using a temporary variable.

C program to swap two numbers without using a temporary variable









 #include<stdio.h>
 int main()
{
    int num1=10,num2=20;
    num1=num1+num2;
    num2=num1-num2;
    num1=num1-num2;
    printf("After swap two numbers \n");
    printf("num1=%d , num2=%d ",num1,num2);
    return 0;

}

0 comments:

Post a Comment