Find the best tutors and institutes for Tuition

Find Best Tuition

No matching category found.

No matching Locality found.

Search for topics

# Write a program to swap values of two variables with and without using third variable.

With third variable Swap(a,b): c=a a=b b=c Without third variable Swap(a,b): a = a+b b= a-b a= a-b read more

With third variable

Swap(a,b):

c=a

a=b

b=c

Without third variable

Swap(a,b):

a = a+b

b= a-b

a= a-b

Programming is an creative Art . I help students to be creative artist by learning coding skill.

A=2 B=4 A=A+B B= A-B A=A-B

Student who can understand problems of other students better

Enter value of x,y than x = x+y than y = x-y than x = x-y print swapped value x,y.

Certified Tamil Teacher with 25 Years of Professional Teaching Experience

With 3rd Variable: int temp, a, b; temp = a; a = b; b = temp; Without 3rd Variable: int a,b; a = a + b; b = a - b; a = a - b;

Programming Language Instructor in C, C++, JAVA.

If you are coding in C++ language then this will help you: #include<iostream.h> int main(){ int a=10, b=20; a=a+b; b=a-b; a=a-b; cout<<a<<" "<<b; return 0; }

TRAINER AND EXPERT IN TEACHING

Hello sir, You can motivate the child by saying, " if you study, then I will give you chocolate (or whatever he likes)."

TRAINER AND EXPERT IN TEACHING

#include<stdio.h> int main() { int a=10, b=20; printf("Before swap a=%d b=%d",a,b); a=a+b;//a=30 (10+20) b=a-b;//b=10 (30-20) a=a-b;//a=20 (30-10) printf("\nAfter swap a=%d b=%d",a,b); return 0; }

Computer science teacher and Mathematics Teacher with 4 years of experience

enter value of x,y than x = x+y than y = x-y than x = x-y print swapped value x,y.

Professional Trainer with 6 years of experience Programming

#include<iostream>int main() { int a=10, b=20; a=a+b; b=a-b; a=a-b; cout<<"After swap a="<<a<<" b="<<b; return 0; } read more

#include<iostream>
int main()
{
int a=10, b=20;
a=a+b;
b=a-b;
a=a-b;
cout<<"After swap a="<<a<<" b="<<b;
return 0;
}

Experienced IT Trainer, Academic Associate, IT Enthusiast

In Python, its dramatically easy, X = 15 Y = 10 X, Y = Y, X

Related Questions

2 days ago
10

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Related Lessons

Chapter 1: Introduction part 1
Hello, first chapter is an Introduction. So, Let's start with introducing our subject. Name of our subject is BASIC MECHNICAL ENGINEERING. so if we divide the name what we'll get..? First word is...
N

Nidhi R. | 3 days ago

How to greet people in German Language?
Let's see how do we greet/wish people in German Language. Guten Morgen = good morning Hallo= hello Guten Tag = good afternoon/good day Guten Abend = good evening Gute Nacht = good night Tschüss...

Prachi P. | 29 Apr

What is Strain Rate ?
Strain rate is how fast the strain is happening with respect to time dE/dt. In a quasi static test like a tensile test the strain rate is of the order of .001 per sec. For a slow phenomenon like creep...

Ashique Ellahi | 28 Apr

Find Tution near you

Looking for Tuition ?

Find best Tuition in your locality on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

### Looking for Tuition Classes?

Find best tutors for Tuition Classes by posting a requirement.

• Post a learning requirement
• Get customized responses
• Compare and select the best

### Looking for Tuition Classes?

Find best Tuition Classes in your locality on UrbanPro

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more