Swap Two Numbers Without Using Third Variable in C# | C Sharp Interview Questions
Вставка
- Опубліковано 12 чер 2020
- Swap two numbers without using third variable using C#.
Buy full Data structure course from www.questpond.com/learn-data-...
For more such videos visit www.questpond.com
See our other Step by Step video series below :-
For more such videos subscribe / questpondvideos
JavaScript Interview Questions: • JavaScript Interview Q...
C# interview questions and answers:- • C# Interview Questions...
ASP.NET MVC Interview Questions with answers:- • ASP.NET MVC Interview ...
Angular Interview Questions and Answers :- • Angular Interview Ques...
C# tutorial for beginners(4 hrs):- • C# Tutorial for Beginn...
Learn Azure Step by Step:- • Azure Tutorial for Beg...
Azure AZ-900 fundamentals certification :- • AZ 900 Certification |...
AZ- 204 certification Azure:- • Azure 204 Certificatio...
Learn Angular tutorial step by step tinyurl.com/ycd9j895
Learn MVC 5 step by step in 16 hours:- • Learn ASP.NET MVC 5 ( ...
Learn Design Pattern Step by Step goo.gl/eJdn0m
Learn MSBI Step by Step in 32 hours:- goo.gl/TTpFZN
Learn SQL Server Step by Step tinyurl.com/ja4zmwu
Python Tutorial for Beginners:- • Python Tutorial for Be...
Learn Data Science in 1 hour :- tinyurl.com/y5o7qbau
Learn Power BI Step by Step:- tinyurl.com/y6thhkxw
PHP Interview Questions : • PHP Interview Question...
-----------------------------------------------------------------------------------------------
For more details :-
🌐 Website : www.questpond.com
📱 Mob. No. : +91-9967590707 / +91 7700975156 / +91-22-49786776
📧Email : questpond@questpond.com / questpond@gmail.com / questpond@yahoo.com
Share, Support, Subscribe and Connect us on!!!
UA-cam: / questpondvideos
Twitter: / questpond
Instagram : / questpond
Facebook : / questpond
#LearnSwapTwoNumberswithoutUsingThirdVariable #C#Questions #C#InterviewQuestionandAnswers #CsharpInterviewQuestions #C#InterviewQuestionsforExperiencedProfecsnals #InterviewQuestionsforC# C#Concepts
ASP.NET, C# Job Market : ua-cam.com/video/H3JEWAp32-s/v-deo.html
Software Architecture Interview Questions : ua-cam.com/video/AtTgcbLOqMM/v-deo.html
25+ OOPS Interview Questions : ua-cam.com/video/u99wAoBjDvQ/v-deo.html
30 Important C# Interview Questions : ua-cam.com/video/BKynEBPqiIM/v-deo.html
20+ SQL Server Interview Questions : ua-cam.com/video/SEdAF8mSKS4/v-deo.html
10+ Power BI Interview Questions : ua-cam.com/video/Cozc9WNBRt4/v-deo.html
20 MSBI Interview Questions : ua-cam.com/video/Nw_sHEKnOUE/v-deo.html
SQL Server Joins : ua-cam.com/video/KTvYHEntvn8/v-deo.html
SQL Step by Step - ua-cam.com/video/uGlfP9o7kmY/v-deo.html
Angular Step by Step Tutorial for Beginners : ua-cam.com/video/-9VcW7MBDs8/v-deo.html
25 Angular Interview Questions : ua-cam.com/video/-jeoyDJDsSM/v-deo.html
25 Important ASP.NET Interview Questions : ua-cam.com/video/pXmMdmJUC0g/v-deo.html
35 Important JavaScript Interview Questions : ua-cam.com/video/Zb4dPi7CANU/v-deo.html
20 MySQL Interview Questions : ua-cam.com/video/9hfjC-BpY20/v-deo.html
5 MSBI Interview Questions : ua-cam.com/video/5E815aXAwYQ/v-deo.html
20 PHP Interview Questions : ua-cam.com/video/1bpNSynUrl8/v-deo.html
If one of them is negative or both Positive numbers
int a,b;
Console.WriteLine("Enter first value");
a=int.Parse(Console.ReadLine());
Console.WriteLine("Enter second value");
b=int.Parse(Console.ReadLine());
Console.WriteLine("a:{0} and b: {1}",a,b);
a=a-(-b);
b=a-b;
a=a-b;
Console.WriteLine("a:{0} and b: {1}",a,b);
But what if one of them is negative number or infinite number ?... :-) Write down in comment other ways of solving this problem.
A neat math trick, but, please, don't anybody ever do this in production code, just use a temp variable. There is nothing simpler than t = a; a = b; b = t;. Any tricks you use will almost certainly be slower and will definitely be less maintainable to future developers.
Sometimes interviewer ask this question dear
I agree so much. But its sad interviewers asks these kind of Questions or they part of aptitude for freshers. As a developer we should follow KIS ( Keep it Simple). But then there is other world out their who hires developers on these criterias. Happy learnig,
X = X+Y
Y = X-Y
X = X-Y