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

The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

964


Differentiate fundamental data types and derived data types in C.

807


What is output redirection?

882


What are the types of unary operators?

865


What is the difference between near, far and huge pointers?

814


Can a variable be both static and volatile in c?

792


Do you know pointer in c?

793


How can you find the day of the week given the date?

829


What does c in a circle mean?

759


Explain the process of converting a Tree into a Binary Tree.

2380


What is a sequential access file?

852


while initialization of array why we use a[][2] why not a[2][]...?

2077


Can you write the algorithm for Queue?

1739


What is the difference between a string and an array?

903


What are header files and what are its uses in C programming?

836