Ask Question
6 March, 13:38

Consider the program segment below. What will be displayed if the user inputs 78?

Scanner sc=new Scanner (System. in);

double[ ] grades=new double[1];

System. out. println ();

for (inti=0; i

System. out. print ("Enter the grade for index ["+i+"]--> ");

grades[i]=sc. nextDouble ();

}

+5
Answers (1)
  1. 6 March, 17:01
    0
    If we analyze the lines of codes, the execution of "for" statement may land up in error. The first statement will receive the input from the user. Next a variable "grades" is declared as double. Next and empty line will get printed using "Println () " function. Next a for loop runs.

    Usually for loop should contain initialization, test condition and the increment value. Here, the initialization is done, but the condition is not provided properly and the syntax is not followed which may yield an error.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Consider the program segment below. What will be displayed if the user inputs 78? Scanner sc=new Scanner (System. in); double[ ] grades=new ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers