Why do we use temp in cpp | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Why do we use temp in cpp

23rd Oct 2019, 4:47 AM
Narendra Mnr
Narendra Mnr - avatar
2 Antworten
+ 6
They are useful for example in swapping two numbers/variables. The use of temp variables is not limited to C++ however languages like Python have constructs like the following to swap the values of two variables without using a temp variable. a, b = b, a
23rd Oct 2019, 6:53 AM
Sonic
Sonic - avatar
+ 1
Temp is often a variable used to store a value temporary.
23rd Oct 2019, 4:52 AM
Seb TheS
Seb TheS - avatar