004-003-008

Basic Array Operations

Easy

Problem Description

Basic Array Operations

In this problem, you will create a program that reads array size, elements, modification index, and new value from standard input, then performs element access, modification, and full traversal, displaying results to standard output.

Learning Objective: Understand basic array operations including element access, modification, and getting length

Overview

Create a program that builds an integer array from standard input and performs basic operations (element access, modification, traversal).

Input Format

n
a[0] a[1] ... a[n-1]
modIndex
newValue
  • Line 1: array size n
  • Line 2: n space-separated integers
  • Line 3: index to modify modIndex
  • Line 4: new value newValue

Specifications

  1. Build an integer array from input
  2. Output the array length
  3. Output the element at index 0
  4. Change the element at modIndex to newValue
  5. Output all elements after modification

Output Format

Length: <n>
First element: <a[0]>
After modification: <elements space-separated>

Sample I/O

Input:
5
10 20 30 40 50
2
100

Output:
Length: 5
First element: 10
After modification: 10 20 100 40 50

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up