without using arthematic operation ,how can you write the
logic for adding/substraction/multiplication?

Answer Posted / sankar

Without using arthematic operation adding two numbers:

#include<stdio.h>
int main()
{
int a=5,b=6;
while(b)
{
a=a^b;
b=(a^b)&b;
b=b<<1;
}
printf("The sum of a and b is: %d\n",a);
return 0;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is boolean in java?

513


What is public static?

497


Java openings 3 - 5 years, Lnt Infotech. requirements - core java, J2ee, struts, hibernate Interview Date:- 19 March 2011 Time:- 9:00 AM to 12:00 Pm Interview Location - L & T Infotech, Manapakkam, Chennai Refererral PS NO:- 291649 (Please mention this when u fill the form only then u will be considered for interview) Documents Required:- Latest Resume, Photograph and last 3 payslips Mail me on vasan2211@gmail.com once u appear for interview

2856


Can we convert stringbuilder to string in java?

562


What is scope & storage allocation of global and extern variables? Explain with an example

581






What are packages in java?

566


Can a main method be overloaded?

574


What is public static void main?

571


What is finalize()?

608


How finally used under exception handling?

516


This abstract class is correct ? abstract class A { public abstract void Disp(); public abstract void B() { } public absract virtual C() { } }

563


Explain the use of sublass in a java program?

599


how come we know the object is no more used in the class?

5435


Is Java a dying language?

573


How to split a string in java?

628