0
0
Cprogramming~20 mins

Common array operations - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Array Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of array sum calculation
What is the output of this C program that sums elements of an integer array?
C
#include <stdio.h>

int main() {
    int arr[] = {1, 2, 3, 4, 5};
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        sum += arr[i];
    }
    printf("%d\n", sum);
    return 0;
}
A10
B15
C5
D0
Attempts:
2 left
💡 Hint
Add all numbers in the array: 1 + 2 + 3 + 4 + 5.
Predict Output
intermediate
2:00remaining
Output of array element modification
What is the output of this C program that modifies elements of an array?
C
#include <stdio.h>

int main() {
    int arr[3] = {10, 20, 30};
    for (int i = 0; i < 3; i++) {
        arr[i] = arr[i] * 2;
    }
    for (int i = 0; i < 3; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}
A20 40 60
B10 20 30
C0 0 0
D30 40 50
Attempts:
2 left
💡 Hint
Each element is multiplied by 2.
Predict Output
advanced
2:00remaining
Output of searching for an element in array
What is the output of this C program that searches for a value in an array?
C
#include <stdio.h>

int main() {
    int arr[] = {5, 10, 15, 20, 25};
    int target = 15;
    int found = 0;
    for (int i = 0; i < 5; i++) {
        if (arr[i] == target) {
            found = 1;
            break;
        }
    }
    if (found) {
        printf("Found\n");
    } else {
        printf("Not Found\n");
    }
    return 0;
}
A0
BNot Found
C15
DFound
Attempts:
2 left
💡 Hint
Check if 15 is in the array.
Predict Output
advanced
2:00remaining
Output of array reversal
What is the output of this C program that reverses an array and prints it?
C
#include <stdio.h>

int main() {
    int arr[] = {1, 2, 3, 4};
    int n = 4;
    for (int i = 0; i < n / 2; i++) {
        int temp = arr[i];
        arr[i] = arr[n - 1 - i];
        arr[n - 1 - i] = temp;
    }
    for (int i = 0; i < n; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}
A4 3 2 1
B1 2 3 4
C2 1 4 3
D1 4 3 2
Attempts:
2 left
💡 Hint
The program swaps elements from start and end.
🧠 Conceptual
expert
2:00remaining
Number of elements in a statically declared array
Given the declaration int arr[10];, what is the value of sizeof(arr) / sizeof(arr[0]) in C?
ADepends on compiler
B4
C10
D40
Attempts:
2 left
💡 Hint
sizeof(arr) gives total bytes, sizeof(arr[0]) gives bytes per element.