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 |
Write a program to print numbers from 1 to 100 without using loop in c?
what is difference between null and nul in c language
What is formal argument?
What is the use of pragma in embedded c?
Develop a program that computes the new price of an item. The program should receive a character variable colour and a double precision floating-point variable price from the user. Discount rate is determined based on the colour of the discount sticker, as shown in the following table. An error message should be printed if an invalid colour has been entered
write a program structure to find average of given number
wats SIZE_T meant for?
what is the use of macro program
What are the differences between new and malloc in C?
string reverse using recursion
What is the advantage of an array over individual variables?
What is the output of the following program #include<stdio.h> main() { int i=0; fork(); printf("%d",i++); fork(); printf("%d",i++); fork(); wait(); }