How to add two numbers without using arithmetic operators?
Answer Posted / selloorhari
#include <stdio.h>
int add(int a, int b)
{
if (!a)
return b;
else
return add((a & b) << 1, a ^ b);
}
int main()
{
unsigned int a,b;
printf("Enter the two numbers: \n");
scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}
Is This Answer Correct ? | 168 Yes | 30 No |
Post New Answer View All Answers
What are the keywords in c?
What is bubble sort technique in c?
What are the difference between a free-standing and a hosted environment?
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
What is the size of empty structure in c?
What is a built-in function in C?
which of the following shows the correct hierarchy of arithmetic operations in C a) (), **, * or/,+ or - b) (),**,*,/,+,- c) (),**,/,*,+,- d) (),/ or *,- or +
What is a pragma?
Explain the ternary tree?
What is the use of typedef in c?
What do header files do?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
What is data type long in c?
Discuss the function of conditional operator, size of operator and comma operator with examples.
What is .obj file in c?