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 263 times
Edit
3
Community EvaluationsNo one has reviewed this question yet, be the first!
2
Write a C program to calculate the total number of sweets.2
Include a .h library in C1
What does the following code refer to: C:\ProgramFiles\QtCreator\text.txt ? 7
What is the size of a long long in C++?1
Write a C function to swap two integers.3
Write a C program that calculates the average of two notes.3
Undefined behavior.