#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; }
Not possible. Let's not forget than in C the followings are all operators:+, -+=, -=++, --=&, *, []function-call
You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;
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.
Quite a few. Some of them are: , () [] & * . -> + ++ += - -- -= * / % *= /= %= ! == <= >= < > != << >> >>= <<= & | ^ ~ &&
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)); } }
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 >>, <<, and the bitwise operators, |, &, ^. 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.
Not possible. Let's not forget than in C the followings are all operators:+, -+=, -=++, --=&, *, []function-call
You can swap two integers without temporary storage by bitwise exclusive-or'ing them in a specific sequence...a ^= b;b ^= a;a ^= b;
Without any operators, 5917 = 5917
Calculus Magic!
The following cases are all possible:- program without any for and while- program without for- program without while- program with both for and while
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.
Quite a few. Some of them are: , () [] & * . -> + ++ += - -- -= * / % *= /= %= ! == <= >= < > != << >> >>= <<= & | ^ ~ &&
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)); } }
The required c program is given below /*Swapping(interchange) the two entered numbers*/ #include<stdio.h> main() { /*Without using third variable*/ int a,b,t; printf("Enter a:"); scanf("%d",&a); printf("Enter b:"); scanf("%d",&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); }
using max function
Without knowing which qualities you are asking about, it is impossible to answer this question.