State whether the following are valid switch statements

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

State whether the following are valid switch statements. If not, explain why. Assume that n and digit are int variables.
a. switch (n <= 2)
{
case 0:
cout << "Draw." << endl;
break;
case 1:
cout << "Win." << endl;
break;
case 2:
cout << "Lose." << endl;
break;
}
b. switch (digit / 4)
{
case 0,
case 1:
cout << "low." << endl;
break;
case 1,
case 2:
cout << "middle." << endl;
break;
case 3:
cout << "high." << endl;
}
c. switch (n % 6)
{
case 1:
case 2:
case 3:
case 4:
case 5:
cout << n;
break;
case 0:
cout << endl;
break;
}
d. switch (n % 10)
{
case 2:
case 4:
case 6:
case 8:
cout << "Even";
break;
case 1:
case 3:
case 5:
case 7:
cout << "Odd";
break;
}

Reference no: EM13339793

Questions Cloud

Evaluate swobodavilles financial condition : Evaluate Swobodaville's financial condition based on the partial list of factors given. That is, consider any observable trends in the data and what they could potentially mean. To compare the data, in some cases it is best to convert dollar figur..
What is the magnitude of the flux through the rectangle : In a uniform electric field of magnitude E, the field lines cross through a rectangle of area A at an angle of 79.0° with respect to the plane of the rectangle. What is the magnitude of the flux through the rectangle
What could it or should it have done differently : How good, or bad, a job has the federal reserve bank done over the last two years? Why? What could it or should it have done differently? Why? Please provide references to support your position.
What is the linear charge density of the line of charge : An electron is suspended at a distance of 1.38 cm above a uniform line of charge. What is the linear charge density of the line of charge. Ignore end effects.
State whether the following are valid switch statements : State whether the following are valid switch statements. If not, explain why. Assume that n and digit are int variables.
Calculate the wavelength of the interfering waves : Two sinusoidal waves traveling in opposite directions interfere to produce a standing wave with the wave function y = (1.00) sin(0.800x) cos(300t), Determine the wavelength of the interfering waves
What are the operating risks of the company : What are the operating risks of the company and what is the financial risk of the company (the debt to total capitalization ratio)?
What is the range of wavelengths of this sound in air : Bats emit a wide variety of sounds, one type emits pulses of sound having a frequency between 39kHz and 78kHz. What is the range of wavelengths of this sound in air
Shows the effect of the preceding statements : The following program shows the effect of the preceding statements.

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