Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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

When is a “switch” statement preferable over an “if” statement?

0 Answers  


Write a simple code fragment that will check if a number is positive or negative.

0 Answers  


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

0 Answers  


What's wrong with "char *p = malloc(10);" ?

4 Answers  


What's a "sequence point"?

3 Answers  






why wipro wase

0 Answers   Wipro,


what is difference b/w extern & volatile variable??

6 Answers   Teleca,


mplementation of stack using any programing language

1 Answers   Marlabs,


c program to add and delete an element from circular queue using array

3 Answers  


why in C,C++'s int size is 2 byte and .net(c#) int Size is 4 byte?

2 Answers  


Explain what is the difference between #include and #include 'file' ?

0 Answers  


Explain low-order bytes.

0 Answers  






Categories