Live Webinar: Prompt Engineering: Skill Everyone Must Learn Today
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Swap Two Numbers Without using Third Variable in C#
WhatsApp
Kailash Chandra Behera
11y
203
k
0
1
25
Blog
Introduction
The given below code swaps two given values of variables without using the third variable in C#.
namespace
CDEMO.
{
class
Program
{
static
void
Main
(
string
[
] args)
{
int
first
,
second
;
first
= 1;
second
= 2;
first
= first + second;
second
= first - second;
first
= first - second;
Console
.
WriteLine
(
first
.
ToString
(
));
Console
.
WriteLine
(
second
.
ToString
(
));
Console
.
ReadLine
(
);
}
}
}
People also reading
Membership not found