write a program to swap Two numbers without using temp variable.
Answer Posted / sneha
two ways to swap a number....
1st method
main()
{
int a,b;
printf("enter two numbers for swaping");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d,b=%d",a,b)
getch()
}
2nd method
main()
{
int a,b;
printf("enter two numbers for swaping");
scanf("%d%d",&a,&b);
a=a*b;
b=a/b;
a=a/b;
printf("a=%d,b=%d",a,b)
getch()
}
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
#include
For what purpose null pointer used?
Can math operations be performed on a void pointer?
Linked lists -- can you tell me how to check whether a linked list is circular?
When should a far pointer be used?
What is far pointer in c?
What are the disadvantages of external storage class?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;
What does c value mean?
What is the use of getch ()?
How can you increase the size of a statically allocated array?
I need a help with a program: Write a C program that uses data input in determining the whole of points A and a whole of circles B. Find two points in A so that the line which passes through them, cut through the maximum number of circles.
An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?
What is conio h in c?