0

how do I get an output of '2' in the program below? int main() { int arr[] = { 3, 1, 2, 5 }; count<<arr[ ]; what do I need to insert in this program to give me an output of '2' ? Thanks

27th Sep 2016, 4:59 PM
Ibim
3 Réponses
+ 1
First of all change count into cout. Then for output arr[2], because you want output as 2 and array 2nd location contains the value as 2. arr[0]=3, arr[1]=1, arr[2]=2, and arr[3]=5. Array index starts from 0 always.
27th Sep 2016, 6:14 PM
mahesh kumar
mahesh kumar - avatar
+ 1
since array start from a[0] therefore to get 2 as output we have to write cout <<a[2] int main() { int arr[] = { 3, 1, 2, 5 }; cout<<arr[ 2];
27th Sep 2016, 6:17 PM
deepak
deepak - avatar
0
2
28th Sep 2016, 9:20 AM
Digvesh Kumar
Digvesh Kumar - avatar