Write a function which returns 1 that 2 is passed and return 2 when 1 is passed.
A simple solution is to compare the passed value with 1 and 2.
Another solution is to use subtraction
We can also use bitwise xor operator.
This article is contributed by Anuj. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
- Write your own atoi()
- Write your own strcmp that ignores cases
- Write an Efficient Method to Check if a Number is Multiple of 3
- Write an Efficient C Program to Reverse Bits of a Number
- Python map function | Count total set bits in all numbers from 1 to n
- Adobe ( Product development) Internship Interview
- XOR of a submatrix queries
- Maximum Bitwise AND pair from given range
- Iterating over all possible combinations in an Array using Bits
- Sum of bitwise AND of all subarrays
- Sum of XOR of all subarrays
- Modify a binary array to Bitwise AND of all elements as 1
- Adobe Interview for Summer Internship 2019
- Find the values of X and Y in the Given Equations