Forums.Sureshkumar.net : A Perfect Place to Share Knowledge         Blogs     Games    Magazines    

"Sharing knowledge does not lessen your store, often it gets you more. Sharing plays a key role in relationships and bonding, happens in small steps and is assisted through community membership."

Go Back   SURESHKUMAR.NET FORUMS > TECHNICAL DISCUSSIONS > JAVA Technologies
Register FAQ Members List Calendar Games Blogs Search Today's Posts Mark Forums Read

   

Reply
 
LinkBack Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 11-02-08, 04:05 PM   #1 (permalink)
Junior Member
 
Join Date: Feb 2008
Posts: 25
Thanks: 3
Thanked 2 Times in 2 Posts
Thanks: 3
Thanked 2 Times in 2 Posts
Rep Power: 1 bharathi chowdary will become famous soon enough
how to add two numbers without using arithmetic and unary operators......

how to add two numbers without using arithmetic and unary operators......
bharathi chowdary is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 04-06-08, 03:19 PM   #2 (permalink)
Junior Member
 
Join Date: Jun 2008
Age: 25
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1 nrganesh.java is on a distinguished road
Re: how to add two numbers without using arithmetic and unary operators......

Quote:
Originally Posted by bharathi chowdary View Post
how to add two numbers without using arithmetic and unary operators......
nrganesh.java is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 05-06-08, 03:38 PM   #3 (permalink)
Super Moderator
 
sk_kireeti's Avatar
 
Join Date: Feb 2006
Location: Hyderabad
Posts: 2,355
Thanks: 117
Thanked 241 Times in 198 Posts
Thanks: 117
Thanked 241 Times in 198 Posts
Blog Entries: 4
Rep Power: 51 sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute sk_kireeti has a reputation beyond repute
Re: how to add two numbers without using arithmetic and unary operators......

Code:
#include <stdio.h>
      int add(int a, int b){
            if (!a) return b;
            else
                 return add((a & b) << 1, a ^ b);
      }

      int main(){
      int a,b;
	    printf("Enter the two numbers: \n");

            scanf("%d",&a);
            scanf("%d",&b);
            printf("Sum is: %d",add(a,b));
      }
__________________
Give 1 cup rice to a hungry Indian just by a mouse click. No money, no form filling, no hassle... Click here for the donation.
sk_kireeti is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to sk_kireeti For This Useful Post:
bharathi chowdary (30-06-08)
Old 30-06-08, 05:56 PM   #4 (permalink)
Junior Member
 
Join Date: Apr 2008
Location: Pune
Age: 25
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1 sandy_rgpv is on a distinguished road
Re: how to add two numbers without using arithmetic and unary operators......

we have the function Add in c and c++ just include the Math.h file.....
and use the function.......
sandy_rgpv is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 17-07-08, 10:50 PM   #5 (permalink)
Junior Member
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1 sagarmv is on a distinguished road
Re: how to add two numbers without using arithmetic and unary operators......

Hi,
This is fine for int values. But it is not working for float/double values. how to do for that values.
sagarmv is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +6.5. The time now is 03:10 AM.





Search Engine Optimization by vBSEO 3.1.0