write a program to swap Two numbers without using temp variable.
Answer Posted / rakesh
#include<stdio.h>
#include<conio.h>
void main()
{
int a=10,b=8;
a=a+b;//a=10+8=18
b=a-b;//b=18-8=10
a=a-b;//a=18-10=8
//hence a=8,b=10
}
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What are the types of arrays in c?
how to create duplicate link list using C???
What are the different types of linkage exist in c?
Give the rules for variable declaration?
What is a void * in c?
What is pass by value in c?
What is data structure in c language?
What is enumerated data type in c?
What are the different types of endless loops?
Can we declare variables anywhere in c?
What is the use of function in c?
Can you please explain the difference between strcpy() and memcpy() function?
I heard that you have to include stdio.h before calling printf. Why?
Which of these functions is safer to use : fgets(), gets()? Why?
Given only putchar (no sprintf, itoa, etc.) write a routine putlong that prints out an unsigned long in decimal. [ I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer wasn't too pleased and asked me to give a solution which didn't need the array ].