🎓C++ series >>> 2nd output question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

🎓C++ series >>> 2nd output question

what is the output of int arr[3]={1,2,3}; cout<<arr[2];

17th Jun 2017, 4:04 PM
#Happy@777
#Happy@777 - avatar
6 Answers
+ 10
3. The index's of the array go like this: arr: {1, 2, 3} Index: 0 1 2 The element at the index of 2 has a value of 3. So, when you write myArr[x], you are getting the value of the element at the index of x.
17th Jun 2017, 4:08 PM
Rrestoring faith
Rrestoring faith - avatar
+ 8
3
17th Jun 2017, 4:07 PM
khadeeja Shamna
khadeeja Shamna - avatar
+ 7
array starts from 0
17th Jun 2017, 4:08 PM
khadeeja Shamna
khadeeja Shamna - avatar
+ 3
explain it Shamna ...
17th Jun 2017, 4:08 PM
#Happy@777
#Happy@777 - avatar
+ 3
quite easy question this time ..... well done you both .... next time i will come with new question .... btw thanks a lot ...
17th Jun 2017, 4:09 PM
#Happy@777
#Happy@777 - avatar
17th Jun 2017, 4:15 PM
#Happy@777
#Happy@777 - avatar