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...

sir i wanted to know how we wap in c to add numbers without
using arithmetic operator in which digits are entered by
user?

Answer Posted / niranjan vg

#include<stdio.h>

int main()
{
int a,b,sum,carry;
printf("\n Enter the numbers : ");
scanf("%d%d",&a,&b);
sum=a^b;
carry=a&b; // Produce a extra carry bit if present
while(carry!=0)
{
carry<<=1; // shift for every iteration so
that it gets added with the next digit
a=sum;
b=carry;
sum=a^b; // perform Xor Operation
carry=a&b; // Calculate the new value for carry
}
printf("\n The sum is %d", sum);
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many keywords (reserve words) are in c?

1105


Suggesting that there can be 62 seconds in a minute?

1016


Why c is called object oriented language?

1024


What is actual argument?

1022


How can I discover how many arguments a function was actually called with?

1036


what are non standard function in c

1875


what is the different bitween abap and abap-hr?

2254


Why are some ANSI/ISO Standard library routines showing up as undefined, even though I've got an ANSI compiler?

1096


how to introdu5ce my self in serco

1965


What is the difference between null pointer and wild pointer?

1158


Write a program to generate a pulse width frequency of your choise,which can be variable by using the digital port of your processor

3489


What is pragma c?

1078


How do I round numbers?

976


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

2138


What is #include cctype?

1086