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

Why dont c comments nest?

625


Write a simple code fragment that will check if a number is positive or negative.

711


How can variables be characterized?

1654


What is meant by initialization and how we initialize a variable?

590


a value that does not change during program execution a) variabe b) argument c) parameter d) none

699






What is the general form of a C program?

600


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1522


Does sprintf put null character?

607


What is the difference between printf and scanf in c?

757


What is structure padding and packing in c?

627


Do you know what are the properties of union in c?

588


What is const keyword in c?

753


The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?

773


Explain what is the benefit of using const for declaring constants?

618


What is scanf () in c?

666