Easy
What is the value of the result variable after executing the following C code?
#include <stdio.h>
int main() {
  int array[] = {1, 2, 3, 4, 5};
  int length = sizeof(array) / sizeof(array[0]);
  int result = 0;
  for (int i = 0; i < length; i++) {
    if (array[i] % 2 == 0) {
      result += array[i];
    }
  }
  printf("Result: %d\n", result);
  return 0;
}
Author: Vincent  CotroStatus: PublishedQuestion passed 340 times
Edit
4
Community EvaluationsNo one has reviewed this question yet, be the first!
8
What is the size of a long long in C++?5
Undefined behavior.1
What does the following code refer to:  C:\ProgramFiles\QtCreator\text.txt ? 1
Write a C program that prints the number of years a child needs to grow to be able to ride a roller coaster.2
Write a C function to swap two integers.3
Write a C program that calculates the average of two notes.2
Write a C program to calculate the total number of sweets.