how to add two numbers without using arithmetic operators?

Answers were Sorted based on User's Feedback



how to add two numbers without using arithmetic operators?..

Answer / sanjay bhosale

int x=12382,y=2;
int xor, and, temp;
and = x & y;
xor = x ^ y;

while(and != 0 )
{
and <<= 1;
temp = xor ^ and;
and &= xor;
xor = temp;
}
printf(" sum is : %d",xor);

Is This Answer Correct ?    0 Yes 0 No

how to add two numbers without using arithmetic operators?..

Answer / shashishekar

#include<stdio.h>
#include<conio.h>
int main()
{
int a= 10;
int b=5;
int sum=0;
sum= a-(~b)-1;
printf(" sum= %d",sum);
getch();
}

Is This Answer Correct ?    0 Yes 0 No

how to add two numbers without using arithmetic operators?..

Answer / mallikarjun

#include<stdio.h>
#include<conio.h>
main()
{
int a= 10;
int b=5;
sum=0;
sum= a&&b;
printf(" sum= %d",sum);
}

Is This Answer Correct ?    9 Yes 10 No

how to add two numbers without using arithmetic operators?..

Answer / rajkumar

#include<stdio.h>
#include<conio.h>
void main()
{
int a=6,b=3,sum=0;
sum=a^b;
printf("sum=%d",sum);
getch();
}

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More C Interview Questions

Q-1: Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college.

8 Answers  


Find if a number is power of two or not?

1 Answers  


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

0 Answers  


c program to print a name without using semicolon

9 Answers   TCS, Wipro,


how to use enum datatype?Please explain me?

3 Answers   Excel,






Reverse a string word by word??

9 Answers  


explain what are actual arguments?

0 Answers  


program to find the roots of a quardratic equation

1 Answers  


What is a function in c?

0 Answers  


any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

0 Answers  


How many header files are in c?

0 Answers  


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

0 Answers  


Categories