Computer Science, asked by abhayr815abh, 3 months ago

Given,
int values[] = {1,2,3,4,5,6,7,8,9,10};
for(int i=0;i< 10; ++i)
System.out.println(values[i]);
Find the value of value[10]?

Answers

Answered by Oreki
3

\textsf{\large \textbf{Given Snippet}}

    \texttt{\hspace{1em} int[] values = \{1, 2, 3, 4, 5, 6, 7, 8, 9, 10\};}

    \texttt{\hspace{1em} for (int i = 0; i &lt; 10; ++i)}

         \texttt{\hspace{2em} System.out.println(values[i]);}

\textsf{\large \textbf{After Execution}}

 \texttt{ 1}

 \texttt{ 2}

 \texttt{ 3}

 \texttt{ 4}

 \texttt{ 5}

 \texttt{ 6}

 \texttt{ 7}

 \texttt{ 8}

 \texttt{ 9}

 \texttt{ 10}

\\\textsf{\large \textbf{Find the value of value[10]?}}

   \text{ Value of \texttt{value[10]} cannot be determined because the array contains}

    \text{ only 10 elements and \texttt{value[10]} tries to fetch a non-existing 11th element.}

Similar questions