How many ways are there to swap two numbers without using
temporary variable? Give the each logic.
Answer Posted / venkatesh sabinkar
as far i know i know two logics they are
first one
void main()
{
int a,b;
printf("eneter any two values");
scanf("%d%d",&a,&b);
a=a+b;
b=a-b;
a=a-b;
printf("a=%d\nb=%d",a,b);
getch():
}
second one
void main()
{
int a,b;
printf("eneter any two values");
scanf("%d%d",&a,&b);
a=a*b;
b=a/b;
a=a/b;
printf("a=%d\nb=%d",a,b);
getch():
}
| Is This Answer Correct ? | 24 Yes | 1 No |
Post New Answer View All Answers
Define VARIABLE?
What are 'near' and 'far' pointers?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
What is output redirection?
Is c procedural or functional?
How do you search data in a data file using random access method?
When should a type cast not be used?
What are the 5 types of organizational structures?
For what purpose null pointer used?
What does dm mean sexually?
Explain modulus operator. What are the restrictions of a modulus operator?
hi send me sample aptitude papers of cts?
Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)
A float occupies 4 bytes in memory. How many bits are used to store exponent part? since we can have up to 38 number for exponent so 2 ki power 6 6, 6 bits will be used. If 6 bits are used why do not we have up to 64 numbers in exponent?
How can I discover how many arguments a function was actually called with?