Determine whether the follwing array declarations are valid, if a declaration is invalid, explain why: d. double[-50] ratings[]; e. string flowers[35]; f. int SIZE = 10; double sales[2 * SIZE]; g. int MAX_SIZE = 50; double sales[100 - 2 * MAX_SIZE];

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

Determine whether the follwing array declarations are valid, if a declaration is invalid, explain why:
d. double[-50] ratings[];

e. string flowers[35];

f. int SIZE = 10;
double sales[2 * SIZE];

g. int MAX_SIZE = 50;
double sales[100 - 2 * MAX_SIZE];

Expert Solution
Step 1

(d)

 

The declaration is invalid due to multiple reasons. Firstly the array size should be specified after the array name, secondly the array size has to be a positive number. The correct declaration is double ratings[50];

 

(e)

 

The declaration is valid.

steps

Step by step

Solved in 2 steps

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