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

What is getch?

1193


What is difference between function overloading and operator overloading?

1093


What type is sizeof?

1039


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

3250


Can a function argument have default value?

1155


Explain how can I write functions that take a variable number of arguments?

1081


What is static identifier?

1224


How to delete a node from linked list w/o using collectons?

2782


Describe the steps to insert data into a singly linked list.

1077


What's the best way of making my program efficient?

1110


What do you mean by a local block?

1087


What is calloc() function?

1103


Explain what is the concatenation operator?

1174


What is array within structure?

1129


a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list

1064