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

The statement, int(*x[]) () what does in indicate?

640


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

637


What will the code below print when it is executed?   int x = 3, y = 4;         if (x = 4)                 y = 5;         else                 y = 2;         printf ("x=%d, y=%d ",x,y);

1345


Differentiate call by value and call by reference?

562


Why doesn't C support function overloading?

1607






What are linked lists in c?

645


Give differences between - new and malloc() , delete and free() ?

605


What is the use of in c?

573


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1425


What is the use of structure padding in c?

560


What is the purpose of & in scanf?

589


What is a program flowchart?

596


How can I pad a string to a known length?

608


disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit

1621


What is fflush() function?

639