Latest Tutorials| Questions and Answers|Ask Questions?|Site Map




Have Programming Question? Ask it here!
 
 
 


kanishasrathod
confusion
1 Answer(s)      3 years and 3 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


Advertisement
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 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
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
Methods - OOP
it sounds like overloading methods would produce a lot of confusion, but it really reduces the confusion. You can also define a method in one... in a different class. This is not called overloading, and there can be no confusion
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
FileFilter
that is shown by setting the file filter for a file chooser dialog. Name Confusion... leads to confusion. javax.swing.filechooser.FileFilter - Use with JFileChooser
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
This series of progressive examples shows a typical pattern for building simple applications with a window.
to change between an application and an applet without confusion... to confusion with no special advantage. If moves the relatively
About Examples
between an application and an applet without confusion... to confusion with no special advantage. If moves
Methods - Introduction
of the program, which prevents accidental errors or confusion
Latitude and Longitude of Guinea-Bissau
independence in 1973 and to avoid the confusion with its name similar to Guinea, the name
How do I track how many hits my website gets
confusion.  Unique- the number of people that visited your site
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
JPanel - Container
in the change from Java 1.1 to 1.2). To add to the confusion BorderLayout
Shadow variables are evil
to a lot of confusion. My advice is never shadow a variable. Setter methods
GPS for Alzheimer's Patients
over 65 years of age and is recognized by confusion, irritability and aggression
Outsourcing Guidelines,Successful Guidelines on Outsourcing,Useful Guidelines on Outsourcing
of the outsourced project. If such confusion occurs in the middle
Best iPhone Accessories and Attachments
accessories all around confusion and doubt is bound to arise. But fear not, our
Ant Custom Properties
a prefix to avoid confusion and possible namespaces clashes. The simplest
Apache Log4J is the leading logging framework in Java.
facade with 61 per cent supporters. There may be some confusion for the actual
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
Class and Interface Concepts
of the parameters so that there is no confusion. This really has nothing to do
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
that a crisis witnessed when confusion creates after organizational misdeeds. To deal
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
Successful Outsourcing Relationship,Managing Successful Outsourcing Relationship
of contact, as this helps to avoid confusion. A good way to do this is to have
XML Interviews Question page15,xml Interviews Guide,xml Interviews
and a source of much confusion, so we will repeat it: THE XML NAMESPACES
Alternate Layout Managers
modified versions of the TableLayout source. This is to prevent confusion
Packages and Import
classes. import FAQ Q: Does importing all classes in a package make my object... for symbols. Q: Is it less efficient to import all classes than only... difference. Q: Doesn't it provide better documentation to import each class
JEE - Java Enterprise Edition
. There are various Java Platforms, which creates confusion among the developers
Lower Risk Business Process,Lower Risk in Business Process Outsourcing
great deal of delay and confusion, unless the parties employ a seamless
 

 

 

DMCA.com