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

  Construct vector and linked lists data structures

You will prepare sorted versions of the Linked Lists and Vector data structures developed in class

  Const int num_years

How do you get this program to get both player input and then display results(As described on bottom) #include  const int NUM_YEARS=15;//The number of years const int NAME_SIZE=32;//The max size of the player name string

  In psuedocode, design an application

In psuedocode, design an application that has an array of at least 20 integers. It should call a module that uses the sequential search algorithm to locate one of the values

  Use a define statement to create a constant

Follow these specifications: Use a define statement to create a constant that will hold your student number. You should have separate string variables for your first and last name; name these first_name and last_name.

  Design and implement a library system

Design and implement a library system that does the following: ? Takes details of a student/library users: first name, last name, other names, user ID number, and nationality.

  Loops and if conditions

Write a program that requests a password

  Make a game in which you guess a number

Make a game in which you guess a number between two set numbers to find the answer, the game should tell you if you are too low in your guess or too high. For example

  Write a program the contains an array of 1000 elements name

Write a function named equals() that accepts two char arrays and return true if both arrays have the same characters in the same order. The function should return false otherwise. Write a simple main() function to test your function.

  Design a deck plan space ship in eclipse

Develop a simple interactive two-dimensional spaceship deck plan editor using OpenGL and GLUT. Your program will enable a user to create and save a deck plan of a hypothetical spaceship comprising the hull walls.

  Program to compute diameter in centimeters of a steel rod

Write a program to compute the diameter in centimeters of a steel rod, an aluminum rod, and a copper rod, which can withstand a particular compression load.

  Calculates the student * averages and quiz averages based

Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output s..

  Prepare a program that uses the pthread library

Prepare a C/C++ program that uses the PTHREAD library to create threads and mutexes to synchronize them.

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