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
What is const and volatile in c?
How can my program discover the complete pathname to the executable from which it was invoked?
Why is c used in embedded systems?
What are reserved words?
What is c programing language?
Why is void main used?
Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?
What does %p mean?
What is malloc return c?
What does sizeof int return?
Why are all header files not declared in every c program?
Explain argument and its types.
What are dangling pointers in c?
Define the scope of static variables.
Why c is known as a mother language?