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

  Write program in c to calculate diameter-compression load

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

  Write a program that plays a tic-tac-toe game.

Using functional decomposition, write a program that plays a tic-tac-toe game.

  Calculate that implements a simple arithmetic calculator

Write a  C program  calc.c that implements a simple arithmetic calculator. Input to the calculator consists of lines composed of integer constants separated by the five arithmetic operators used in C: +, -, *, /, and %. For each line of input,

  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

  Takes a string containing a full name

Write a program that takes a string containing a full name and outputs each part of the name separately with its length. The name should be in the form of first, middle, and last name, separated from each other by a single space. For example, if the ..

  Create a file, shared.txt

When your program starts, it shall do the following:1. Create a file, SHARED.txt, in the current directory (cwd). 2. Write it's pid (Process ID) followed by a Carriage Return and Newline in the file.

  Find the pairs in any given matrix

write a c program which will find the pairs in any given matrix, whose sum of pairs are 10.

  Write a program that skip s leading whitespace character

a) Write a program that skip s leading whitespace character s in each line of the pro vided data file CPPHumor .txt . Save the results in a new file

  Design a nested program

How many levels of nesting are there in this design?

  Create a template class

Create a template class, SVector, that implements a constructor

  Write a c function void print_triangle(int n)

Write a C function void print_triangle(int n) that prints a triangular pattern of asterisks of height n and width 2 * n + 1 with one asterisk in the first line, three in the second line, etc.,

  Computer programming techniques

Construct a program from a design and use appropriate functions

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