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


Please Help Members By Posting Answers For Below Questions

what is associativity explain what is the precidence for * and & , * and ++ how the folloing declaration work 1) *&p; 2) *p++;

1999


Which is the memory area not included in C program? give the reason

1499


What are the advantages of using linked list for tree construction?

639


What is the usage of the pointer in c?

599


using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1306






What would the following code segment printint k = 8;docout << "k = " << k << " ";while k++ < 5; a) 13 b) 5 c) 8 d) pointers

670


What is the difference between array_name and &array_name?

774


Where is volatile variable stored?

640


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3136


What are the three constants used in c?

539


Is main is a keyword in c?

602


Write a program to reverse a given number in c language?

616


What are the different types of errors?

635


What is extern keyword in c?

637


Which function in C can be used to append a string to another string?

639