luc059.c¶
Problem Statement
Write a program which initializes an integer array of 10 elements in main(), passes it to modify(), multiplies each element by 3, and prints the new array in main().
Metadata¶
| Property | Detail |
|---|---|
| Author | Amit Dutta amitdutta4255@gmail.com |
| Date | 08 Feb 2026 |
| License | MIT License (See the LICENSE file for details) |
| Difficulty | Beginner (index: 1 / 10) |
Concepts¶
Beta Feature
This concept detection system is still in beta and may occasionally show incorrect or incomplete results.
- Array
- Pointers
- Iteration
- Sorting (possible)
- Recursion
Actions¶
You can print or save this file by opening Raw and using your browser.
Source Code¶
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void modify(int *, int);
int main()
{
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int i;
printf("Original Array:\n");
for (i = 0; i < 10; i++)
printf("%d ", arr[i]);
modify(arr, 10);
printf("\n\nModified Array (x3):\n");
for (i = 0; i < 10; i++)
printf("%d ", arr[i]);
printf("\n");
return 0;
}
void modify(int *a, int n)
{
int i;
for (i = 0; i < n; i++)
{
a[i] = a[i] * 3;
}
}
Explanation¶
Explain with AI
Copy the prompt below and paste it into any AI assistant.
You are explaining a C programming code to a beginner.
STRICT RULES:
- Only use the given code. Do NOT assume anything not present.
- Do NOT add extra examples.
- Keep explanation clear and short.
- If something is unclear, say "Not clear from code".
- Follow the exact format below. Do NOT change headings.
FORMAT:
[START]
## What it does
(Explain the overall purpose in 1-2 sentences)
## Step-by-step
(Explain how the code works in steps, simple language)
## Key Concepts
(List concepts like loop, condition, function, etc.)
## Notes
(Mention any limitations, errors, or assumptions)
[END]
CODE (luc059.c):
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
void modify(int *, int);
int main()
{
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
int i;
printf("Original Array:\n");
for (i = 0; i < 10; i++)
printf("%d ", arr[i]);
modify(arr, 10);
printf("\n\nModified Array (x3):\n");
for (i = 0; i < 10; i++)
printf("%d ", arr[i]);
printf("\n");
return 0;
}
void modify(int *a, int n)
{
int i;
for (i = 0; i < n; i++)
{
a[i] = a[i] * 3;
}
}