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 pointers in c with example?
What are the types of type qualifiers in c?
How to print "Hi World" without using semi colon?
How can I read data from data files with particular formats?
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.
what is the benefit of c30
What is an expression?
Write a small C program to determine whether a machine's type is little-endian or big-endian.
What is the use of clrscr?
Can a file other than a .h file be included with #include?
What is the difference between test design and test case design?
What is stack in c?