Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Development-process xor operator not working correctly with array
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


satyam kumar
xor operator not working correctly with array
1 Answer(s)      a year and 8 months ago
Posted in : Development process


main
{
  int a[2] = {2,3};
  printf("before swapping: %d %d\n",a[0],a[1]);
  //a[0] ^= a[1];
  //a[1] ^= a[0];
  //a[0] ^= a[1];  //this is working correctly.

  a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why?

  printf("after swapping: %d %d\n",a[0],a[1]);
}

Advertisement
View Answers

February 15, 2013 at 5:56 PM


hi friend,

This is because the XOR operator is valid for only two operands.

For detail tutorial please go through the following link

http://www.roseindia.net/java/master-java/java-bitwise-xor.shtml



Related Tutorials/Questions & Answers:
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0...",a[0],a[1]); }   hi friend, This is because the XOR operator is valid
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
Advertisements
xor operator not working correctly with array
xor operator not working correctly with array  main { int a[2...] ^= a[0]; //a[0] ^= a[1]; //this is working correctly. a[0] ^= a[1] ^= a[0] ^= a[1]; //this didn't work correctly why? printf("after swapping: %d %d\n
Comparing arrays not working correctly?
Comparing arrays not working correctly?  Comparing arrays not working correctly
Java Bitwise XOR "^" Operator
Java Bitwise XOR "^" Operator   ... of  bitwise XOR "^" operator. Description of code: The bitwise XOR...:\unique>java BitwiseXOR ^ XOR operator 1 ^ 0 = 1 C:\unique>
Java XOR Operator
Bitwise XOR (exclusive or) "^" is a Java operator.... But  if both of the bits are same then the XOR operator gives the result 0. Following example will show how to use "^" operator in Java. XOR
Java XOR operator
Java XOR operator       Java makes available the bitwise operators like AND, OR, XOR, and NOT. ... of  the XOR operator.  It requires at least two  bit
Using [] operator of EL with an Array
Using [ ] operator of EL with an Array   .... The [] operator is much more powerful than the dot, because it lets you access.... An array is a type of container which can hold a fixed number of values of a single
PHP Array Operator
Array Operators: In PHP there are many operators are available which works on more than one array, to get union of two arrays, to check the identity, equality etc. '+' operator is used to get the union of two arrays
Mysql XOR
Mysql XOR       Mysql XOR returns you the output on the basis of condition specified in input. The output of the XOR is 0 when both the specified inputs are same. The output is 1
Show XOR Mode
Show XOR Mode       In this section, you will studied about the XOR mode.  XOR or Exclusive Or returns true only if both its operands have different values. The XOR shows
FORM Tag Correctly for Uploading Files.
FORM Tag Correctly for Uploading Files.  How To Write the FORM Tag Correctly for Uploading Files?   Hi friends, When you clicks the submit... a complete FORM tag for file uploading: How To Write the FORM Tag Correctly
What is the % operator?
What is the % operator?   Hi, What is the % operator? thanks
AND operator in hibernate.
AND operator in hibernate.  How to use AND operator in hibernate
OR operator in hibernate.
OR operator in hibernate.  How to use OR operator in hibernate
How To Write the FORM Tag Correctly for Uploading Files?
How To Write the FORM Tag Correctly for Uploading Files?  How To Write the FORM Tag Correctly for Uploading Files
Data is not inserting correctly in mysql database.
Data is not inserting correctly in mysql database.  Hello Sir, below is my code to insert data into database by list iteration through for loop but it is not getting inserted ..it is taking only one value
Java operator
Java operator  Which Java operator is right associative
Java operator
Java operator  What is the difference between the prefix and postfix forms of the ++ operator
Java operator
Java operator  What are the legal operands of the instanceof operator
like operator
like operator  how to select exact value using like operator in php
Java Array Initialization
to the array object. The correct way to use the "new" operator is  String... Java Array Initialization       After declaring an array variable, memory is allocated
ternary operator
ternary operator  (Ternary operator) Dearness Allowance= 25% of Basic pay house rent allowance= 15% of basic pay Provident fund= 8.33% of Basic pay Net pay=basic pay+Dearness allowance+house rent allowance Gross pay= Net pay
LIKE Operator
LIKE Operator       The LIKE operator is used for searching  a specified pattern in the column. In this example we will show you how to use the Like operator to get
What is the difference between the Boolean & operator and the && operator?
What is the difference between the Boolean & operator and the && operator?   Hello, What is the difference between the Boolean & operator and the && operator? thanks
SQL IN Operator
SQL IN Operator       SQL IN Operator helps you to specify multiple values in a WHERE Clause... IN Operator. In this example, we create a table 'Stu_Table'. The create
Checking elsewhere with correctly blocked code and question
Checking elsewhere with correctly blocked code and question  Hi I have already posted this question but realised I had made a few mistakes. So firstly the problem again!. I have a textarea box for user comments which will return
UITapgesturerecognizer not working
UITapgesturerecognizer not working  uitapgesturerecognizer not working
C Array length example
of an array in C. An array is a contiguous group of data items with the same name and data type. In order to get the length of an array, we have used the sizeof operator... C Array length example     
htpasswd working
htpasswd working   hii, What does htpasswd do?   hello, htpasswd creates a new user in a specified group, and asks to specify a password for that user
c++ operator overloading
c++ operator overloading  What is operator overloading? and what is mean by overloading?? Can anyone please explain the concept in regards to C
Advertisements
 

 

 

DMCA.com