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


Please Help Members By Posting Answers For Below Questions

What is omp_num_threads?

577


What are qualifiers?

615


What are the advantages of using Unions?

642


What are the different categories of functions in c?

640


What is the use of structure padding in c?

561






What is the difference between a function and a method in c?

558


How are structure passing and returning implemented?

588


write a C program: To search a file any word which starts with ?a?. If the word following this ?a? starts with a vowel.Then replace this ?a? with ?a? with ?an?. redirect with the output onto an output file.The source file and destination file are specified by the user int the command line.

2449


What is the scope of local variable in c?

574


What are the output(s) for the following ? #include char *f() {char *s=malloc(8); strcpy(s,"goodbye")} main() { char *f(); printf("%c",*f()='A'); }

694


What is the importance of c in your views?

586


What is the collection of communication lines and routers called?

608


Hai what is the different types of versions and their differences

1484


What is time null in c?

579


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

648