Ask Question
8 March, 11:54

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 ();

}

+3
Answers (1)
  1. 8 March, 11:59
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers