answersLogoWhite

0


Best Answer

#include<stdio.h> int main() { int n,n2; printf("enter the no. < 15 "); // here i am considering the case of 4 bits. (1111) binary = (15) decimal scanf("%d",&n); n2=n^10; /* 10 = 1010 in binary form, to invert its even bits , we will use bit wise XOR (^) operator 1010 has 1 at its even places, so it will invert the even bits of n. if there is any further problem mail me at buntyhariom@gmail.com www.campusmaniac.com */ printf("\n%d",n2); return 0; }

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program to illustrate bitwise operators without swap?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How-to to add to values in java core without using plus operator?

Though Java, unlike other languages, does not allow you to directly access the core, memory addresses and system variables, it does have binary operators, such as the shifters &gt;&gt;, &lt;&lt;, and the bitwise operators, |, &amp;, ^. Using these operators, ALL calculations in the computer can be done, even your complicated trig functions. Though options are limited in Java, it does provide a simulated access to low level operations. The bitwise operators are in the link below. Look at the link below to see how the computer really does math.


How a program in c that will add 2 numbers without using any operator?

Not possible. Let's not forget than in C the followings are all operators:+, -+=, -=++, --=&, *, []function-call


What are the conditions to swap in c plus plus without temporary?

You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;


What is 59 17 equal?

Without any operators, 5917 = 5917


How do you add two numbers without any operators in maths?

Calculus Magic!


Is it possible to make a program using for and not with while?

The following cases are all possible:- program without any for and while- program without for- program without while- program with both for and while


How do you compare two numbers without using any operators in c?

You cannot compare 2 numbers without using relational operators. Certainly, you could subtract them, but you still need to test the result, and that is a relational operator in itself.


How many operators in c?

Quite a few. Some of them are: , () [] &amp; * . -&gt; + ++ += - -- -= * / % *= /= %= ! == &lt;= &gt;= &lt; &gt; != &lt;&lt; &gt;&gt; &gt;&gt;= &lt;&lt;= &amp; | ^ ~ &amp;&amp;


Addition of two numbers without using operators in java?

I don't think this can be done. Why do you want to do it without operators, anyway? It is fairly simple to use them. - Of course, you could write a method that adds two numbers, but your method will internally still have to use operators. ----------------------------------------- Reply by lordstriker24@yahoo.com import java.math.BigInteger; public class MultiplyTest { public static void main(String[] args) { BigInteger bigInt1 = new BigInteger("5"); BigInteger bigInt2 = new BigInteger("8"); System.out.println(bigInt1.add(bigInt2)); } }


What is program in c to swap entered two numbers without using third variable?

The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include&lt;stdio.h&gt; main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&amp;a); printf("Enter b:"); scanf("%d",&amp;b); a=a+b; b=a-b; a=a-b; printf("\n After swapping without using third variable"); printf("\na=%d\nb=%d",a,b); }


How do you compare 2 numbers without using relational operators in c?

using max function


What example from Whitney Houston illustrate these qualities?

Without knowing which qualities you are asking about, it is impossible to answer this question.