swapping of two numbers without using third variable using
AND and OR operators
Answers were Sorted based on User's Feedback
Answer / ramesh reddy
a = a^b; b =a^b; a =a^b;
or
a=a+b; b=a-b; a=a-b;
| Is This Answer Correct ? | 43 Yes | 2 No |
however we can implement using EXoR , where it is made of
AND and OR gate too....
x=90;
y=51;
x^=y^=x;
the value of x & y will be swapped.
| Is This Answer Correct ? | 8 Yes | 8 No |
Write a program to swap two numbers without using third variable in c?
main() { int a[3][4] ={1,2,3,4,5,6,7,8,9,10,11,12} ; int i, j , k=99 ; for(i=0;i<3;i++) for(j=0;j<4;j++) if(a[i][j] < k) k = a[i][j]; printf("%d", k); }
4 Answers Vector, Wipro, Zoho,
What's the difference between DELETE TABLE and TRUNCATE TABLE commands?
what are the facialities provided by you after the selection of the student.
what are two kinds of java
Are there namespaces in c?
we compile c program in 32 processor and 64 bit processor .exe file is created in both the processors. if we want to run .exe file in 64 bit processor which is created in 32 bit processor. is that .exe file is run or not if it is not run why?
Explain the process of converting a Tree into a Binary Tree.
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
Explain what is a program flowchart and explain how does it help in writing a program?
Can I initialize unions?
how to write a c program to print list of fruits in alpabetical order?