How many ways are there to swap two numbers without using
temporary variable? Give the each logic.
Answer Posted / vignesh1988i
as for i know their are two different logics for the
swapping techinque.... swapping is a type of techinque used
for interchanging the two varibles in the operating
memory....
1) using only variables
2) using EX-OR operator '^'
first logic only know.
void main()
{
int a,b;
printf("enter the a&b");
scanf("%d%d",&a,&b);
a+=b;
b=a-b;
a-=b;
printf("a=%d\nb=%d",a,b);
getch();
}
Is This Answer Correct ? | 48 Yes | 4 No |
Post New Answer View All Answers
How do I get an accurate error status return from system on ms-dos?
Write a program to reverse a given number in c?
Explain what are reserved words?
if the area was hit by a virus and so the decrease in the population because of death was x/3 and the migration from other places increased a population by 2x then annually it had so many ppl. find our the population in the starting.
Explain enumerated types.
What are the 4 types of programming language?
What is difference between array and pointer in c?
What are predefined functions in c?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
What are types of structure?
What is property type c?
Explain the advantages of using macro in c language?
What is meant by 'bit masking'?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.
What is the argument of a function in c?