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
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 |
Answer / sheshivardhan reddy.rayala
using aadd()function we can add the arguements without
using arithmetic operator
Is This Answer Correct ? | 1 Yes | 2 No |
What is the advantage of c?
Program to find largest of three numbers without using comparsion operator?
What is a protocol in c?
What is the size of empty structure in c?
Why doesnt this code work?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
what is the purpose of the code, and is there any problem with it. bool f( uint n ) { return (n & (n-1)) == 0; }
Why ca not I do something like this?
Does c have an equivalent to pascals with statement?
Does sprintf put null character?
Write a program to remove the C comments(/* */) and C++ comments(//) from a file. The file should be declared in command line.
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)