1. Print Array Elements

EasyArrayArray

Given an integer array nums, print all of its elements in order, separated by spaces.

Write a function that takes the array and prints its elements (it does not need to return anything). This is a warm-up to get comfortable reading an array and printing output.

Input: An array of integers nums.

Output: The elements printed in order (a single space between them; nothing for an empty array).

Examples

Example 1
Input: nums = [1, 2, 3, 4, 5]
Output: 1 2 3 4 5
Explanation: Print each element in order.
Example 2
Input: nums = [10]
Output: 10
Explanation: A single element.
Example 3
Input: nums = [-1, 0, 5]
Output: -1 0 5
Explanation: Negatives are printed as-is.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →