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
Is it better to use malloc() or calloc()?
What is a pointer value and address in c?
What is the purpose of void in c?
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
How can I write a function that takes a format string and a variable number of arguments?
Explain how are portions of a program disabled in demo versions?
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.
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
You are to write your own versions of strcpy() and strlen (). Call them mystrcpy() and mystrlen(). Write them first as code within main(), not as functions, then, convert them to functions. You will pass two arrays to the function in the case of mystrcpy(), the source and target array.
A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference
What is the difference between pure virtual function and virtual function?
Why void is used in c?
How to declare a variable?
what is the difference between 123 and 0123 in c?
#include