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

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

using arithmetic operator

 Is This Answer Correct ? 1 Yes 2 No

More C Interview Questions

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

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

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.

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

What's a "sequence point"?

why wipro wase

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

mplementation of stack using any programing language

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

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

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

Explain low-order bytes.

Categories