Online Compiler C

#include <stdio.h> void add_value(int* a, int n, int x) { for (int i = 0; i < n; i++) { a[i] = a[i] + x; } } int main() { int n, x; scanf("%d %d", &n, &x); int a[100]; for (int i = 0; i < n; i++) { printf("%d\n", a[i]); } return 0; }
This code defines a function `add_value` that adds a value `x` to each element of an array, but the function is never called in `main`. The `main` function reads two integers `n` and `x`, then prints the uninitialized array `a` without ever filling it with values or calling `add_value`.

- The array `a` is declared with size 100 but never given any initial values. Printing `a[i]` before assigning values will output garbage data.
- The function `add_value` is defined but never used. You need to call it after reading input and before printing, and you must first fill the array with numbers (for example, by reading them from input).