write a program to swap Two numbers without using temp variable.
Answer Posted / tamal datta
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
printf("\n Enter a = ");
scanf("%d",&a);
printf("\n Enter b = ");
scanf ("%d",&b);
printf ("\nBefore swapping a = %d",a);
printf ("\nBefore swapping b = %d",b);
//swaping of 2 numbers without using temp variable
a=a+b;
b=a-b;
a=a-b;
printf("\nAfter swapping a = %d",a);
printf ("\nAfter swapping b= %d",b);
getch();
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
What are file streams?
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
What are the three constants used in c?
How can I handle floating-point exceptions gracefully?
Can a void pointer point to a function?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
Why use int main instead of void main?
Write a program to reverse a string.
Explain the difference between structs and unions in c?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
Explain the use of keyword 'register' with respect to variables.
Why void main is used in c?
Tell me what are bitwise shift operators?
Write a program to implement queue.
Explain built-in function?