Ask Question

What is printed by the following program? var numApples = 10; var numOranges = 5; if (numApples < 20 || numOranges = = numApples) { println ("Hello, we are open!"); } else { println ("Sorry, we are closed!"); } println ("Sincerely, the grocery store");

+5
Answers (1)
  1. 12 August, 07:41
    0
    The output of the following code is "Hello, we are open! Sincerely, the grocery store ".

    Explanation:

    In the given code firstly we declare the variable that is numApples and numOranges. In this variable we assign value and the datatype of the variable is var. The var datatype can hold any type of data. Then we use the conditional statement. In the conditional statement, we use the OR logical operator. In the if block we check the condition that is if numApples variable value is less then 20 OR numOranges variable value is equal to numApples then it will print "Hello, we are open!". In the else block it will print "Sorry, we are closed!". In the last, we print "Sincerely, the grocery store". So in this question, if block is executed and the additional message is printed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What is printed by the following program? var numApples = 10; var numOranges = 5; if (numApples < 20 || numOranges = = numApples) { println ...” 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