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
3 Respuestas
+ 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.
+ 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];
0
2