Java For the following int[] array, print out the elements and their corresponding sqaure. int[] num = {1,2,3,4,5,6}; The output should be: 1    1 2    4 3    9 4   16 5   25 6   36

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Java
For the following int[] array, print out the elements and their corresponding sqaure.

int[] num = {1,2,3,4,5,6};

The output should be:

1    1

2    4

3    9

4   16

5   25

6   36

 

Note: You must use array operation involving a loop utilizing array subscripts. Don't hardcode the printout.

Note: You can use the following code framework to start coding.

public class CST1201Test3

{

    public static void main(String[] args)

    {

         int[] num = {1,2,3,4,5,6};

        // your answer

    }

}

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage