Change Password
Logout
Update Question
View
Question
<p dir="ltr">What will be the output of the following code snippet?</p> <p dir="ltr">void solve()</p> <p dir="ltr"> { int a[] = {1, 2, 3, 4, 5}; </p> <p dir="ltr">int sum = 0;</p> <p dir="ltr"> for(int i = 0; i < 5; i++) </p> <p dir="ltr">{ if(i % 2 == 0) { sum += a[i];</p> <p dir="ltr"> } } </p> <p dir="ltr">cout << sum << endl; }</p> <p> </p>
Option 1
<p>5</p>
Option 2
<p>15</p>
Option 3
<p>9</p>
Option 4
<p>6</p>
Correct Answer
Option 1
Option 2
Option 3
Option 4
Submit
Design and Developed by
O7Solutions