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

Answer Posted / ratna

#include<stdio.h>
main()
{
int x,y;
printf("\n enter the two numbers:\n");
scanf("%d%d",&x,&y);
y=(x+y)-y;
x=(x+y)-x;
printf("\n x=%d \n y=%d\n");
getch();
}
output: enter the two numbers:10
20
execute the conditions y=30-20=10
x=30-10=20
finally display the output:20 10

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

606


Tell me can the size of an array be declared at runtime?

591


Can a variable be both constant and volatile?

552


What is selection sort in c?

597


List the difference between a "copy constructor" and a "assignment operator"?

574






What are lookup tables in c?

543


What are the advantages of the functions?

600


Explain what are its uses in c programming?

588


Can math operations be performed on a void pointer?

581


What is indirection in c?

615


What is structure and union in c?

590


Tell me the use of bit field in c language?

621


What is the heap in c?

635


In c programming language, how many parameters can be passed to a function ?

621


What are examples of structures?

583