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 the main use of c where it can use the c

2 Answers   Infosys,


Explain why can’t constant values be used to define an array’s initial size?

0 Answers  


Is it possible to run using programming C for Java Application?

2 Answers   NIC,


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

0 Answers   CLG,


printf(), scanf() these are a) library functions b) userdefined functions c) system functions d) they are not functions

0 Answers  






In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none

0 Answers  


How can you check to see whether a symbol is defined?

0 Answers  


how do you programme Carrier Sense Multiple Access

0 Answers  


what is meant by the "equivalence of pointers and arrays" in C?

3 Answers   Satyam,


What is the scope of local variable in c?

0 Answers  


What is a pointer variable in c language?

0 Answers  


Explain what are the __date__ and __time__ preprocessor commands?

0 Answers  


Categories