loops and arrays - CPSC 1301 Computer Science 1 ARRAYS...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CPSC 1301 – Computer Science 1 LOOPS and ARRAYS Study Sheet Use the following declarations to answer the following questions: const int arraySize = 10; int [] list = new int[arraySize]; double[] sales= {12.25, 32.50, 23.65, 26, -45.67}; String [] names = {“Bai”, “Bosworth”, “Khan”, “Obando”, “Ray”, “Wright”, “Zanev”}; enum paintType {Green, Red, Blue, Brown, White, Orange, Yellow}; int result; int count; int x; int i; Write the output for the following: 1. result = 2; for (count = 0; count <= 5; count++) result += count; System.out.println("result = " + result); 2. x = 1; for (int j = 1; j <= 4; j++) for (int k = 5; k > 0; k--) x++; System.out.println("x= “ + x); 3. result = 9; sum = 0; for (int count = 2; count < result; count += 3) sum += count; System.out.println("sum = " + sum); 4. final int LIMIT = 10; count = 2; while (count < LIMIT) { System.out.print(" " + count); count += 2; }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
System.out.println(“count= “ + count); 5. x=1;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

loops and arrays - CPSC 1301 Computer Science 1 ARRAYS...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online