swap two integer variables without using a third temporary
variable?

Answer Posted / sidhartha

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("\n ENTER 2 VALUES : ");
scanf("%d%d",&a,&b);
printf("\n THE VALUES BEFORE SORTING : %d,%d",a,b);
a=a+b;
b=a-b;
a=a-b;
printf("\n THE VALUES AFTER SORTING : %d,%d",a,b);
getch();
}

Is This Answer Correct ?    40 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can you please explain the difference between syntax vs logical error?

909


Why void main is used in c?

777


Explain bit masking in c?

893


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

907


What are the advantages of the functions?

853


What is this pointer in c plus plus?

794


Write a c program to build a heap method using Pointer to function and pointer to structure ?

4392


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

1153


What is the difference between union and structure in c?

768


Define macros.

1019


Is null valid for pointers to functions?

851


What is the process to generate random numbers in c programming language?

868


What is volatile variable in c?

852


What is a scope resolution operator in c?

949


What are the types of type qualifiers in c?

832