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

Is it better to use malloc() or calloc()?

1102


Is javascript written in c?

1054


What is a protocol in c?

987


any "C" function by default returns an a) int value b) float value c) char value d) a & b

1077


Write a progarm to find the length of string using switch case?

2057


What is null in c?

1080


Describe the order of precedence with regards to operators in C.

1042


Tell us bitwise shift operators?

1089


What is the difference between text files and binary files?

1340


What is difference between %d and %i in c?

1230


What is the difference between new and malloc functions?

1111


What is strcpy() function?

1133


i have a written test for microland please give me test pattern

2728


What is "Hungarian Notation"?

1097


Where are local variables stored in c?

1032