void swap(int a,int b)
{
a=a+b;
b=a-b;
a=a-b;
}
in this code always gives the same result for all case
Answers were Sorted based on User's Feedback
Answer / k.kavitha
NO,if the values of a&b are 10,20 respectively., Then
a=a+b becomes "a=30"
b=a-b becomes b=30-20 i.e., "b=10"
a=a-b gives a=30-10 i.e., "a=20"
| Is This Answer Correct ? | 20 Yes | 6 No |
Answer / moorthy
here a and b are local variable in function swap() where a
and b are swapped inside swap().so that swaping does not
affect variable in main().
| Is This Answer Correct ? | 12 Yes | 1 No |
Answer / prateek
Actually this code is for interchanging values of two
variables without using third variable
| Is This Answer Correct ? | 9 Yes | 1 No |
Answer / mangala pandi p
provided a+b is between the int minimum and int maximum
so the answer is no.
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / shouvik mitra
This code gives the interchange values of the two variables.But this code can also give the same result for the two variables when same numbers are inputted in both the variables, i.e. say a=5,b=5.
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / sayantan ghosh
This will never give a result as its call by value and even the values arnt printed in the function so the values in main will only be present
| Is This Answer Correct ? | 0 Yes | 0 No |
difference between native and cross compilers
What language is lisp written in?
What are void pointers in c?
What is the correct declaration of main?
Why c is called object oriented language?
How can I read a directory in a C program?
2 Answers Bright Outdoor, Wipro,
read a number & print all its devisors using c-program?
biggest of two no's with out using if condition statement
how to find out the union of two character arrays?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
5. What kind of sorting is this: SORT (k,n) 1.[Loop on I Index] repeat thru step2 for i=1,2,........n-1 2.[For each pass,get small value] min=i; repeat for j=i+1 to N do { if K[j]<k[min] min=j; } temp=K[i];K[i]=K[min];K[min]=temp; 3.[Sorted Values will be returned] A)Bubble Sort B)Quick Sort C)Selection Sort D)Merge Sort
Find Error if any in below code, Justify ur answer: struct xx { int a; struct yy { char c; struct xx* p; } struct yy* q; }