confusion

confusion

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:

#include<stdio.h>
#include<conio.h>
int main()
{
    int num1,num2,sum;
    printf("\nEnter 1st number for addition:");
    scanf("%d",&num1);
    printf("\nEnter 2nd number for addition:");
    scanf("%d",&num2);
    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);
    getch();
    return 0;
}









Related Tutorials/Questions & Answers:
confusion
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
Advertisements
ModuleNotFoundError: No module named 'pandas_confusion'
ModuleNotFoundError: No module named 'pandas_confusion'  Hi, My... named 'pandas_confusion' How to remove the ModuleNotFoundError: No module named 'pandas_confusion' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'confusion-matrix'
ModuleNotFoundError: No module named 'confusion-matrix'  Hi, My... named 'confusion-matrix' How to remove the ModuleNotFoundError: No module named 'confusion-matrix' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'confusion-metrics'
ModuleNotFoundError: No module named 'confusion-metrics'  Hi, My... named 'confusion-metrics' How to remove the ModuleNotFoundError: No module named 'confusion-metrics' error? Thanks   Hi, In your
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
Filter/Controller
one is filer. I have confusion with these two. Is there any d/f b/w filter
ecilpse
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?
(CommPortIdentifier.java:105) 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
springs  ir i have the confusion in spring form validation.using hibernate.my 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
. In this scenario another algorithm update may increase confusion, as thought... of the impact on SEO practice, two updates can create confusion among
How do I track how many hits my website gets
; that can cause confusion.  Unique- the number of people
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?
. The participants expressed their concern over the possibility of confusion and anti... other terms that could be used to avoid the confusion and decided upon &lsquo
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
and eventual failure of the outsourced project. If such confusion occurs
GPS for Alzheimer's Patients
over 65 years of age and is recognized by confusion, irritability and aggression
Apache Log4J is the leading logging framework in Java.
be some confusion for the actual successor of the Log4j, but there is no doubt
XML Interviews Question page16,xml Interviews Guide,xml Interviews
://www.google.org}C. Needless to say, this has led to a certain amount of confusion. One area of confusion is the relationship between XML namespaces and validating... namespaces. The other main area of confusion is in recommendations
XML Interviews Question page15,xml Interviews Guide,xml Interviews
and a source of much confusion, so we will repeat it: THE XML NAMESPACES
Successful Outsourcing Relationship,Managing Successful Outsourcing Relationship
a single point of contact, as this helps to avoid confusion. A good way to do
Tips for Successful Outsourcing,Useful Tips of Successful Outsourcing,Tips and Techniques for Successful Outsourcing
there is no confusion or vagueness.ADS_TO_REPLACE_4
Delhi Habitat World Convention Centre Information
Delhi Habitat World Convention Centre In a life full of chaos and confusion we find it tough to spot a serene place to spend a few minutes in peace. To resolve this problem various cultural convention centers are being built around us
How to deal with Crisis management
) In many cases it has been appeared that a crisis witnessed when confusion
What is Digital Relationship?
Basically there is a lot of confusion concerning the meaning, importance and expanse of the term digital relationship. But as we are immersed already in the digital age and everything right from the entertainment to information sharing
5 Reasons Java is Still a Great Language to Boost Your Career Prospect as a Programmer
? If all these questions add to your confusion the current post can help you
VoIP Telephone Adapter
category can lead to confusion. So, please refrain from marketing tricks getting
XML Interviews Question page28,xml Interviews Guide,xml Interviews
. This point causes a lot of confusion, so we'll repeat it here: URIs USED AS XML
Lower Risk Business Process,Lower Risk in Business Process Outsourcing
and different time zones. All this can cause great deal of delay and confusion
JEE - Java Enterprise Edition
, which creates confusion among the developers sometimes but all the platforms
How to Recover a Business from a Google Panda 4.0 Penalty?
confusion may prove to be more challenging for the webmasters. While the focus
Open Source Java
about and executes its open-source strategy. That confusion is evident... that follows an independent course. This could lead to confusion with developers
Installation, Configuration and running Servlets
. In case of doubt or confusion, you can refer to the abundant documentation

Ads