Question
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int array[] = {0, 2, 4, 6, 7, 5, 3};
6.
int n, result = 0;
7.
for (n = 0; n < 8; n++) {
8.
result += array[n];
9.
}
10.
cout
What will be the output of the this program?
1.
#include
2.
using namespace std;
3.
int main ()
4.
{
5.
int array[] = {0, 2, 4, 6, 7, 5, 3};
6.
int n, result = 0;
7.
for (n = 0; n < 8; n++) {
8.
result += array[n];
9.
}
10.
cout
Answer: Option D
Was this answer helpful ?
We are adding all the elements in the array and printing it. Total elements in the array is 7, but
our for loop will go beyond 7 and add a garbage value.
Was this answer helpful ?
More Questions on This Topic :
Question 5.
What is a array?
....
Submit Solution