How to add two numbers without using arithmetic operators?

Answer Posted / srinu

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,i,j,k=0;
printf("enter 2 numbers");
scanf("%d%d",&a,&b);
if(a>b)
{
k=b;
for(i=1;i<=a;i++)
k++;
}
else
{
k=a;
for(j=1;j<=b;j++)
k++;
}
printf("sum of 2 numbers is %d",k);
}

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Find MAXIMUM of three distinct integers using a single C statement

618


What is the maximum length of an identifier?

657


What is strcmp in c?

592


a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion

2330


What is the difference between union and anonymous union?

831






What is the difference between int main and void main?

569


please send me the code for multiplying sparse matrix using c

1717


Can two or more operators such as and be combined in a single line of program code?

799


Does c have an equivalent to pascals with statement?

566


What math functions are available for integers? For floating point?

615


explain how do you use macro?

663


How can you determine the maximum value that a numeric variable can hold?

630


Why pointers are used?

627


Explain how do you override a defined macro?

577


What is c language used for?

551