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
Why clrscr is used in c?
how can f be used for both float and double arguments in printf? Are not they different types?
What is void c?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What is merge sort in c?
Are bit fields portable?
explain what are pointers?
Where can I get an ansi-compatible lint?
What’s the special use of UNIONS?
What is the difference between %d and %i?
What is int main () in c?
One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.
What is #define size in c?
Is c procedural or functional?
explain what is fifo?