+ 2

Program for doing sum of 2 numbers without using '+' operator ?

24th Dec 2017, 4:47 PM
Sandeep Kumar R
Sandeep Kumar R - avatar
4 Respuestas
+ 17
Or we can do :- int a,b,sum; sum = - (-a -b); Just a joke 😂😂😂
24th Dec 2017, 5:27 PM
NITYASTRIKER
NITYASTRIKER - avatar
+ 6
#include<stdio.h> int add(int x, int y) { int a, b; do { a = x & y; b = x ^ y; x = a << 1; y = b; } while (a); return b; } int main( void ){ printf( "2 + 3 = %d", add(2,3)); return 0; } XOR (x ^ y) is addition without carry. (x & y) is the carry-out from each bit. (x & y) << 1 is the carry-in to each bit. The loop keeps adding the carries until the carry is zero for all bits.
24th Dec 2017, 5:20 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
python: class oke: def summing(x, y): return x.__radd__(y) print(oke.summing(10, 5))
25th Dec 2017, 7:17 AM
Kevin AS
Kevin AS - avatar
0
nadie habla español
28th Jan 2018, 10:14 PM
Yovanny Linares
Yovanny Linares - avatar