What will be the result of the following code?#include <stdio.h>int main() { int arr[5] = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < 5; i++) { sum += arr[i]; } printf("%d\n", sum); return 0;}
Question
What will be the result of the following code?#include <stdio.h>int main() { int arr[5] = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < 5; i++) { sum += arr[i]; } printf("%d\n", sum); return 0;}
🧐 Not the exact question you are looking for?Go ask a question
Solution
The result of the code will be 15.
Here's the step by step explanation:
-
An integer array
arrof size 5 is declared and initialized with the values 1, 2, 3, 4, 5. -
An
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.