how to add numbers without using arithmetic operators.
Answer Posted / sneha
#include <stdio.h>
int add(int a,int b)
{
if(!a)
return b;
else
return add((a&b)<<1,a^b);
}
void main()
{
int a=2, b=3, c;
c = add(a,b);
printf("%d\n",c);
}
| Is This Answer Correct ? | 15 Yes | 3 No |
Post New Answer View All Answers
What are pointers?
What is a program flowchart and explain how does it help in writing a program?
If one class contains another class as a member, in what order are the two class constructors called a) Constructor for the member class is called first b) Constructor for the member class is called second c) Only one of the constructors is called d) all of the above
The number of bytes of storage occupied by short, int and long are a) 2, 2 and 4 b) 2, 4 and 4 c) 4, 4 and 4 d) none
How can I ensure that integer arithmetic doesnt overflow?
What is s in c?
Can you write a programmer for FACTORIAL using recursion?
Why can’t constant values be used to define an array’s initial size?
How can you determine the maximum value that a numeric variable can hold?
What's the difference between constant char *p and char * constant p?
What is difference between static and global variable in c?
What is pointer to pointer in c with example?
What is struct node in c?
Explain how can I prevent another program from modifying part of a file that I am modifying?
Is main is a keyword in c?