write a c program to swap the values of interger variables "a" and "b" and display them
Answers
Answered by
0
Answer:
C Program to swap two numbers without third variable
#include<stdio.h>
int main()
{
int a=10, b=20;
printf("Before swap a=%d b=%d",a,b);
a=a+b;//a=30 (10+20)
b=a-b;//b=10 (30-20)
a=a-b;//a=20 (30-10)
Answered by
0
Answer:
#include <stdio.h>
#include <conio.h>
void main ()
{
int a,b;
printf ("enter the value of a and b");
scanf ("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf ("\n after swap it will be=%d%d",a,b);
getch ();
}
Similar questions