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

What is pointers in c with example?

0 Answers  


What are the types of type qualifiers in c?

0 Answers  


How to print "Hi World" without using semi colon?

6 Answers   Infosys,


How can I read data from data files with particular formats?

0 Answers  


Read N characters in to an array . Use functions to do all problems and pass the address of array to function. 1. Print only the alphabets . If in upper case print in lower case vice versa.

1 Answers  






what is the benefit of c30

2 Answers  


What is an expression?

0 Answers  


Write a small C program to determine whether a machine's type is little-endian or big-endian.

5 Answers   nvidia,


What is the use of clrscr?

0 Answers  


Can a file other than a .h file be included with #include?

0 Answers   Aspire, Infogain,


What is the difference between test design and test case design?

0 Answers  


What is stack in c?

0 Answers  


Categories