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?

Answers were Sorted based on User's Feedback



sir i wanted to know how we wap in c to add numbers without using arithmetic operator in which dig..

Answer / 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

sir i wanted to know how we wap in c to add numbers without using arithmetic operator in which dig..

Answer / sheshivardhan reddy.rayala

using aadd()function we can add the arguements without
using arithmetic operator

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Interview Questions

write a program that prints a pascal triangle based on the user input(like how many stages) in an efficient time and optimized code?

3 Answers   Oracle,


Find errors (1) m = ++a*5; (2) a = b ++ -c*2; (3)y = sqrt (1000);

5 Answers  


Why is %d used in c?

0 Answers  


Can static variables be declared in a header file?

0 Answers  


When should the volatile modifier be used?

0 Answers  


What is structure padding ?

3 Answers   HP,


the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters

2 Answers  


print pattern 1 1 33 33 555 555 77777777 555 555 33 33 1 1

1 Answers   Winit,


What is main return c?

0 Answers  


write a code for large nos multilication (upto 200 digits)

2 Answers   Persistent,


Is both getch() and getchar() functions are similar? if it is similar means why these two functions are used for same usage? if it is not similar means what is the difference?

1 Answers   Infosys,


progrem to generate the following series 1 12 123 1234 12345

6 Answers   HCL, Wipro,


Categories