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