What would the practical purpose of this be? If they all are the same why use an array? Why not just use a single integer? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What would the practical purpose of this be? If they all are the same why use an array? Why not just use a single integer?

I feel like using a more complex system to do what a simpler system could do just unnecessarily confuses/complicated the matter, No?

3rd Jun 2019, 4:34 AM
Zach Schmitt
Zach Schmitt - avatar
7 Answers
+ 4
the example may have seemed useless, but arrays are extremely useful. they help save memory and make managing lots of variables easy. if you have 5000 students you wouldnt give each one its own variable. and if you got a new student youd have to add a variable to the source code when you could just use a GUI interface to push the new student into the existing array of students
3rd Jun 2019, 4:44 AM
koala 🐨
koala 🐨 - avatar
+ 2
Zach Schmitt are you referring to this lesson? https://www.sololearn.com/learn/CPlusPlus/1627/ If so, the lesson just want to show that a value gets assigned to each array index when you loop through it.
3rd Jun 2019, 4:44 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
Perfect! Thanks koala 🐨 ! The example just seemef entirely pointless, but if it can be used to do other things than assign the same variable to [infinite] I fully see the value
3rd Jun 2019, 4:53 AM
Zach Schmitt
Zach Schmitt - avatar
0
what is "this" you are referring to?
3rd Jun 2019, 4:37 AM
koala 🐨
koala 🐨 - avatar
0
Arrays in C++. Making an array' s index spit out all the same values was the lesson I just did. Seems pointless
3rd Jun 2019, 4:39 AM
Zach Schmitt
Zach Schmitt - avatar
0
~ swim ~ I am thinking about it and if they are the same number it's stupid and a waste of time to add it in as a code. If it has the same value use the same integer.
3rd Jun 2019, 4:46 AM
Zach Schmitt
Zach Schmitt - avatar
0
So Jonathan Pizarra , am I to assume next lesson it will show the practical application? I guess I should have continued on as I have encountered that before
3rd Jun 2019, 4:48 AM
Zach Schmitt
Zach Schmitt - avatar