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 I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

1076


What do you know about the use of bit field?

1100


What is size of union in c?

1081


What are Macros? What are its advantages and disadvantages?

1221


Is swift based on c?

1150


How can I automatically locate a programs configuration files in the same directory as the executable?

1232


What is c programing language?

1134


Is javascript based on c?

1117


What is a nested loop?

1180


What is array of structure in c programming?

1332


What is the use of sizeof () in c?

1099


Can a variable be both const and volatile?

1190


Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

1131


all c language question

2490


What are external variables in c?

1167