Computer Science, asked by khirwarshourya, 2 months ago

What will be the output of the following program segment- for(i=1;i<=10;i=i+2) { sum=sum+ i; } System.out.println(sum);

25
55
26
24​

Answers

Answered by Oreki
3

\textsf{\large Given Snippet:}

   \texttt{for (i = 1; i &lt;= 10; i = i + 2) \{}

        \texttt{sum = sum + i;}

   \texttt{\}}

   \texttt{System.out.println(sum);}

\textsf{\large Ou \hspace{-0.33em}tput:}

   \texttt{25}

\textsf{\large Explanation:}

   \texttt{As the loo \hspace{-.9em} p calculates sum of all odd numbers until 10.}

Answered by krishnasaranb123
2

Answer:

What will be the output of the following program segment- for(i=1;i<=10;i=i+2) { sum=sum+ i; } System.out.println(sum);

25

55

26

24

Explanation:

hloooooo hiiiiii shouryaa goooddd morning ❤❤❤❤

Similar questions