Subscribe

Header Ads

Write a program in C to swap 2 numbers.( without using 3rd variable)

                   



 Program in C to add 2 numbers 

#include<stdio.h>
#include<conio.h>
int main()
{
int a,b;
printf("Enter the value of a = ");
scanf("%d",&a);
printf("Enter the value of b = ");
scanf("%d",&b);
a=a+b;
        b=a-b;
        a=a-b;
printf(" Value in a = %d \n Value in b = %d",a,b);
return 0;
}

Output:-







Post a Comment

0 Comments