GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  Programming  >  C

 Print  |  
Question:  Sum of two numbers without using arithmetic operators

Answer: ex:
int a=10;
int b=10;
int sum=a+b;
without using "+" operator calculate sum


July 07, 2008 12:44:10 #2
 veeranarayana   Member Since: July 2008    Total Comments: 1 

RE: sum of two numbers without using arithmetic operators
 
int i,j;
if(i<j)
{
     for(i=0;i<=j;i++)
         j++;
    cout<<j;
}
else
{
   for(j=0;j<=i;j++)
       i++;
  cout<<i;
}
     

 

Back To Question