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

What is the purpose of clrscr () printf () and getch ()?

1 Answers  


write a program to display the frequency of each element in a given array in c language

1 Answers  


List the difference between a "copy constructor" and a "assignment operator"?

1 Answers   Accenture,


What is const keyword in c?

1 Answers  


What is a stream?

1 Answers  


what are bit fields in c?

3 Answers  


What are the parts of c program?

1 Answers  


main() { int a[10]; printf("%d",*a+1-*a+3); }

2 Answers  


What is adt in c programming?

1 Answers  


What is the use of pointers in C?

1 Answers   akamai, Impetus, Motorola, Tavant Technologies, Virtusa,


what is the use of bitfields & where do we use them?

2 Answers  


What is c variable?

1 Answers  


Categories