Is it possible to have 2 values to have the same variable? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Is it possible to have 2 values to have the same variable?

I am a Chromebook Tech at a school district. We have thousands of Chromebooks to maintain. each Chromebook has two identifiers on them (the district asset tag and the Chromebook serial number). How do I set one variable to have 2 different values. I want the users to be able to type one of the two values and get the variable. Is this possible?

6th Jul 2018, 1:35 PM
Christopher Gable
Christopher Gable - avatar
7 Answers
+ 4
Answer: You can store one value into one variable at same time. If you want to store another value into that variable it will be replaced. Suggestion: It is better to use dynamic array, it will help you to store values as many as you want at the run time.
10th Jul 2018, 3:55 AM
Pushpajit-Biswas
Pushpajit-Biswas - avatar
+ 2
no it is not possible to have two values of a same variable
6th Jul 2018, 4:22 PM
Sayantan Das
Sayantan Das - avatar
+ 2
I suggest that you should use array function such that !! you can have one variable declared but you can give as many value you want ,just Declare variable name with[] number of time you want it to occur in program ..
15th Jul 2018, 1:49 PM
Harsh Dave
Harsh Dave - avatar
+ 1
I've not much experience in programming but according to my knowledge there can be only one of a variable 'at a time'.
6th Jul 2018, 1:38 PM
Mubasher Ahmad
Mubasher Ahmad - avatar
+ 1
Then you have to use an array
6th Jul 2018, 3:41 PM
Vincent Wegas
Vincent Wegas - avatar
+ 1
Try finding similarities between serial numbers or district asset tags. Like fixed length or some number that pops up when summed all the numbers. So you can write an algorith that says, "Hmm, its a serial number length thing, so it should be a serial number!". If its not a serial number than its a district asset tag probably. You can use it as a shortcut (Bkz: benefits of else). Hope helps : )
7th Jul 2018, 9:39 PM
Mustafa Yıldız
Mustafa Yıldız - avatar
+ 1
no you can't... because it will replace the previous value stored in it.
10th Jul 2018, 5:13 PM
Vipul Bodhani