Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How to add two numbers without using arithmetic operators?

Answer Posted / selloorhari

#include <stdio.h>
int add(int a, int b)
{
if (!a)
return b;
else
return add((a & b) << 1, a ^ b);
}

int main()
{
unsigned int a,b;
printf("Enter the two numbers: \n");

scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}

Is This Answer Correct ?    168 Yes 30 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can a program be made to print the name of a source file where an error occurs?

1216


What is sizeof int?

1092


What are the 4 types of unions?

1034


Explain the use of 'auto' keyword in c programming?

1115


What is a file descriptor in c?

1126


If jack lies on Mon, Tue Wed and jill lies on Thursday, Friday and Saturday. If both together tell they lied yesterday. So c the given options and then c cos in the given dates one will be saying the truth and one will be lying. I got Thursday as option because jack is saying the truth he lied yest but jill is lying again as he lies on that day.

2271


What is wrong with this code?

1177


Explain the concept and use of type void.

1111


Which is the memory area not included in C program? give the reason

1942


Why can't I perform arithmetic on a void* pointer?

1091


What is function and its example?

1207


what is ur strangth & weekness

2416


How can I prevent another program from modifying part of a file that I am modifying?

1051


What are the different types of control structures in programming?

1124


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1087