004-002-008

Arrays: Element Access and Modification

Easy

Problem Description

Arrays: Element Access and Modification

Learning Objective: Understand how to access array elements and modify values

In this problem, you will create a program that reads 5 integers from standard input to build an array, modifies the element at a specified index to a specified value, and displays all elements separated by spaces.

Overview

Create an array that stores 5 integers from input, change the value at the given index, then output all elements.

Specifications

  • Line 1: 5 space-separated integers (initial array values)
  • Line 2: the target index and new value (space-separated)
  • Output all elements of the modified array separated by spaces

Input Format

a0 a1 a2 a3 a4
index newValue

Output Format

a0 a1 ... newValue ... a4

Example

Input:
10 20 30 40 50
2 100

Output:
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