Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  




Share on Google+Share on Google+

1 Answer(s)      6 years and 7 months ago
Posted in : Design concepts & design patterns

how can i write a program to swap a value without using any arithmetic or any other third variable???

and also for adding two numbers without using any arithmetic operator??????? in c language

View Answers

January 24, 2011 at 4:00 PM

Hello Friend,

1)For swapping, use following code:

    int num1=5,num2=10;
    num1 = num1 + num2;
    num2 = num1 - num2;
    num1 = num1 - num2;

2)Add 2 Numbers:

int main()
    int num1,num2,sum;
    printf("\nEnter 1st number for addition:");
    printf("\nEnter 2nd number for addition:");
    char *p;
    p=(char *)num1;
    sum= (int)&p[num2]; //sum of num1 and num2
    printf("\nSum of %d and %d is %d",num1,num2,sum);
    return 0;


Related Tutorials/Questions & Answers:
Confusion on Functions. Help Please?!
Confusion on Functions. Help Please?!  Write a program which has a number of functions for getting the area i.e. area of circle, area of square, area of rectangle and area of cylinder. Right, I've got some of it, but I'm just
Setxx and Getxx - Java Beginners
Setxx and Getxx  Hi! i have just confusion on MVC, like why we are going to use Setxx and Getxx methods. please let me know clearly. Regards Janardhan
JSP - JSP-Servlet
JSP  HI! Thanks for your reply.... The code which you have sent is good, but I am in a little bit confusion that where i have to specify the path of the folder to save the files
swing-awt - Swing AWT
swing-awt  Hi, Thanks for replying to my question...I'm getting some confusion to add action events in my application(Rich Text Editor).How to add action events? Thank U
one is filer. I have confusion with these two. Is there any d/f b/w filter
ecilpse  just now i have entered into IT development field facing many difficulties being a fresher just tel me how to work with eclipse an connection establishment in jdo and html jsp etc.... getting many confusion while writing
Java Final Variable
Java Final Variable  I have some confusion --Final variable has single copy for each object so can we access final variable through class name,or it is necessary to create object for accessing final variable
creating a java bean application - IDE Questions
creating a java bean application  hi, i want to create a java bean using BDK. please tell me all the steps for creating a simple java bean application. i have also a confusion about the properties of java bean. please explain
servlets - Servlet Interview Questions
servlets  more than one webapplication pages are created in one page is possible or not?if possible why? not possible why? give me the clear explanation.  Hi friend, A Little bit Confusion can you clear: *).more
How to send sms alerts to mobile using java?
( confusion is there what is COM2 port and how
servlet - Servlet Interview Questions
servlet  Thanks for the previous answer related to mail server. mMy new qustion is: why we do not need to use main method in a servlet? Is there any afdvantage behind it? please clear my confusion...  Hi friend
Java Thread - Java Beginners
Java Thread  hii i feel confusion in tread. i want to know about 1. currentThread() method 2. notify(), notifyAll() methods 3. execution of a thread.. pls help me in this trouble...  Hi friend, Following
Struts - Struts
Struts  Dear Sir , I am very new in Struts and want to learn about validation and custom validation. U have given in a such nice way to understand but little bit confusion,Plz could u provide the zip for address
java.lang.IllegalArgumentException: node to traverse cannot be null!
i am in a confusion. Please help Thanks Mohan
Session Object from request
confusion is ...session is stored in server, client is stored in client. according
springs  ir i have the confusion in spring form validation.using bean configuration only wrong . i dont know how to map my validator to my controller it is shows errpr like
PHP Assignment Operators
Assignment Operator: We  have used the basic assignment operator in our life but a confusion may occur between an "assignment operator" and "equal to ", though these seems same but in programming languages
Creating Database - SQL
Creating Database  Hi I am Guru I am having the confusion in creating the database.Actually Just I joined one small company. I am fresher. My problem- Specification:I have to create one web site its like
1st 2nd & 3rd Normal Form
confusion is 1st NF No duplicate row Info. So the Normal ex: Not having somthing like
java code implementation - Java Beginners
;Thanks. I got my code to work ok. But your code helps clarify the confusion I had... the confusion I had earlier
Google Panda 4.0 is rolling out
increase confusion, as thought by many SEO experts. Moreover, two back to back... create confusion among the webmasters and even for the evaluation of Google
How do I track how many hits my website gets
confusion.  Unique- the number of people that visited your site
Latitude and Longitude of Guinea-Bissau
independence in 1973 and to avoid the confusion with its name similar to Guinea, the name
What is Open Source?
their concern over the possibility of confusion and anti-commercial implications... that could be used to avoid the confusion and decided upon ‘open source&rsquo
PHP Addition of Array
PHP Addition an Array to Another Array In this PHP beginners tutorial we will study to add an array into another array, don't be confused with array merge and addition of arrays, given example will clear the confusion, in the given
PHP User Authentication Login and password check Tutorial
to lessen any confusion. And that's it. You can access it by start to linking
Ant Custom Properties
a prefix to avoid confusion and possible namespaces clashes. The simplest
Best iPhone Accessories and Attachments
accessories all around confusion and doubt is bound to arise. But fear not, our
Outsourcing Guidelines,Successful Guidelines on Outsourcing,Useful Guidelines on Outsourcing
of the outsourced project. If such confusion occurs in the middle
GPS for Alzheimer's Patients
over 65 years of age and is recognized by confusion, irritability and aggression