1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sergey [27]
2 years ago
11

What is wrong, logically, with the following code? if (x > 10) System.out.println("Large"); else if (x > 6 && x &l

t;= 10) System.out.println("Medium"); else if (x > 3 && x <= 6) System.out.println("Small"); else System.out.println("Very small");
Computers and Technology
1 answer:
Alex73 [517]2 years ago
8 0

Answer:

The above code will hold the second condition with && operator, like "x<=6" or"x<=10" condition in the else if statement which is of no use.

Explanation:

  • The above code holds a condition-based statement by the help of if-else statement where--
  • The first if-condition will states true when the value of x will be greater than 10, So the if-else condition will be tested for that value of x which is less than or equal to 10.
  • So there is no needs to justify the " x <= 10" for else if statement and " x <= 6" for the second else if statement because the second else if statement will be tasted when the value of x will be less than or equal to 6.
You might be interested in
Write a method swaparrayends() that swaps the first and last elements of its array parameter. ex: sortarray = {10, 20, 30, 40} b
Alexus [3.1K]
In the C programming language, you can't determine the array size from the parameter, so you have to pass it in as an extra parameter. The solution could be:

#include <stdio.h>

void swaparrayends(int arr[], int nrElements)
{
int temp = arr[0];
arr[0] = arr[nrElements - 1];
arr[nrElements - 1] = temp;
}


void main()
{
int i;
int myArray[] = { 1,2,3,4,5 };
int nrElements = sizeof(myArray) / sizeof(myArray[0]);
swaparrayends(myArray, nrElements);

for (i = 0; i < nrElements; i++)
{
printf("%d ", myArray[i]);
}

getchar();
}

In higher languages like C# it becomes much simpler:

        static void Main(string[] args)
        {
            int[] myArray = {1, 2, 3, 4, 5};
            swaparrayends(myArray);
            foreach (var el in myArray)
            {
                Console.Write(el + " ");
            }

            Console.ReadLine();
        }

        static void swaparrayends(int[] arr)
        {
            int temp = arr[0];
            arr[0] = arr.Last();
            arr[arr.Length - 1] = temp;
        }

3 0
3 years ago
How to boost audio live ​
Masteriza [31]
Huh


Hzhanajsjjajajans
6 0
3 years ago
Write an if/else statement that assigns 0 to x when y is equal to 10; otherwise it should assign
Liono4ka [1.6K]

Answer:

if(y==10)

{

     x=0;   // assigning 0 to x if y equals 10.

}

else

{

   x=1;   // assigning 1 to x otherwise.

}

Explanation:

In the if statement i have used equal operator == which returns true if value to it's right is equal to value to it's left otherwise false.By using this operator checking value of y and if it is 10 assigning 0 to x and if it is false assigning 1 to x.

7 0
2 years ago
My dog peed in the house last week
Solnce55 [7]

Answer:

my dog chewed up the couch

Explanation:

5 0
3 years ago
Read 2 more answers
Which of the following statements is not true? Group of answer choices
Nesterboy [21]

Answer:

A

Explanation:

Option A is not true because a Boolean variable type can hold one of two values only that is  (true/True or false/False).

All the other options given in the question are correct because

  1. A variable declaration refers to specifying its type and name
  2. If string variables are assigned a numeric values which is legal provided the values are enclosed in quaotes( " "), trying to carryout a mathematical operation like addition will result in string concatenation.
  3. The Variable name I_Love_to_eat_pizza is legal because it contains no special characters, doesn't start with a number and its not a reserved word in any language
4 0
3 years ago
Other questions:
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • What can you do with someone's ip address?
    9·1 answer
  • I want to know all part of computer system?
    9·2 answers
  • Whether you work in m-commerce, e-commerce, or brick-and-mortar commerce, to be successful you will need to be able to think cri
    15·1 answer
  • Help me decide this hurry
    12·1 answer
  • Your company just installed a new web server within your DMZ. You have been asked to open up the port for secure web browsing on
    5·1 answer
  • A program that doesn’t work properly needs to be debugged. true or false
    8·1 answer
  • Which path needs to be followed to change the currency settings of Windows Operating System?
    14·1 answer
  • Out-of-order instruction execution can cause problems because a later instruction may depend on the results from an earlier inst
    6·1 answer
  • Create an application that determines the final cost of food items and non-food items, assuming only non-food items are taxed. T
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!