write a program to swap Two numbers without using temp variable.

Answer Posted / insane programmer

#include<stdio.h>
#include<conio.h>

void main()
{
int a=100, b=30;
clrscr();

a = a+b;
b = a-b;
a = a-b;

printf("Swapping without using third variable (using + and -).\n\n");
printf("Value of a=%d and b=%d.", a,b);
getch();
}

you can get more example here http://rajkishor09.hubpages.com/_eknow/hub/How-to-swap-two-numbers-without-using-third-temp-variable

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is union and structure?

567


What do you mean by scope of a variable in c?

540


Differentiate between calloc and malloc.

751


What does *p++ do? What does it point to?

609


What is the difference between single charater constant and string constant?

615






What should malloc() do? Return a null pointer or a pointer to 0 bytes?

617


What is static and auto variables in c?

560


What is a list in c?

612


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

599


How can a process change an environment variable in its caller?

648


What is the usage of the pointer in c?

598


how can i write a program that prints out a box such that whenever i press any key8(coordinate number) on the keyboard, the box moves.

1209


Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10

15043


What is structure data type in c?

563


An integer that indentifies the position of a data item in a sequence of data items a) value b) number c) index d) all of the above

643