Which of the following are valid case statements in a switch

Assignment Help C/C++ Programming
Reference no: EM13162220

int x = 5;
if (x != 2)
     System,out.println( "This is true!");
else
     System.out.println( "This is false!");
     System.out.println("This is all folks!");


a. case 'ab':b.case x < 4:c.case 1:d. case 1.5:
 

4. What is the output of the following code fragment?int i = 2;
switch(i + 1){
    case 0: i = 15; break;
    case 1: i = 25; break;
    case 2: i = 35; break;
    case 3: i = 40; break;
    default: i = 0;
}
System.out.println( i );

5. After execution of the following code, what will be the value of input_value?int input_value = 0;
if (input_value > 5){
      input_value = input_value + 5;
}
else if (input_value > 2){
      input_value = input_value + 10;
}
else {
    input_value = input_value + 15;
}


6.If x has the value of 3, y has the value of -2, and w is 10, is the following condition true or false?
      if ( x < 2 && w < y)



8.What is the output of the following segment of code if 4 is input by the user when asked to enter a number?
int num, total = 0;
Scanner scan = new Scanner(System.in);
System.out.println("Enter a number from 1 to 10: ");
num = scan.nextInt( );
switch (num)
{
    case 1:
    case 2: total = 5;
    case 3: total = 10;
    case 4: total = total + 3;
    case 8: total = total + 6;
    default: total = total + 4;
}
System.out.println( total );
 
10.What is wrong with the following for loop?
   for (int i = 0; i < 10; i -- ){
       System.out.println("Hello");
   }

Reference no: EM13162220

Questions Cloud

What is the value of the money multiplier : What is the value of the money multiplier and What are the nominal values of deposits, currency, and reserves
What equation would be used to solve for the equilibrium : A mixture of 1 atm chlorine gas and 1 atm oxygen gas and no product undergoes this reaction. Cl2 + 2 O2 ---> 2 ClO2 What equation would be used to solve for the equilibrium concentrations
Course textbook many instances : The course textbook provides many instances in which states or groups of states moved to nullify federal laws that they felt were unconstitutional and within their authority not to follow.
What combination of properties is responsible : What combination of properties is responsible for the selection of trinitrotoluene as a military explosive?
Which of the following are valid case statements in a switch : What will following segment of code output? int x = 5; if (x != 2)      System,out.println( "This is true!"); else      System.out.println( "This is false!");      System.out.println("This is all folks!");
What is the percent of carbon in the hydrocarbon : 25g of a hydrocarbon undergoes complete combustion leading to the formation of 77 g of CO2. What is the % of carbon in the hydrocarbon?
Calcutate the molecular weight of surfur : calcutate the molecular weight of surfur if 35.5 grams of sulfur dissolve in 100 grams of CS2 to produce a solution that has a boiling point of 49.48c.
Calculate the pressure of the gas : a sample of chlorine gas occupies a volume of 946ml at a pressure of 726mmhg. Calculate the pressure of the gas in (in mmhg) if the volume is reduced at constant temperatures to 154ml.
Analyze the potential for a collaborative approach : Determine the optimum prices and outputs for both Airbus and Boeing if they decide to proceed individually without collaborating in the development of the VLCT.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd