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

  Data from the file grocery.dat

Read the data from the file Grocery.dat and assign values to the 10  GroceryItem  objects. Next display these items to allow a customer to select grocery items from the list and indicate the quantity of that item he or she would like to order. When t..

  Using array subscript notation

Using array subscript notation, base/offset notation with the array name as the pointer, array notation with  vPtr , and pointer/offset notation with  vPtr , add 3 to the value in the 3 rd element and display that number. (Do not modify the value in ..

  Write a program that inputs a dollar amount to be printed

Write a program that inputs a dollar amount to be printed on a check and then prints the amount in check-protected format with leading asterisks if necessary

  C string and two int reference parameters

Write a complete function, not an entire program, that has a C string and two int reference parameters (call them a and b), returning nothing.

  Write a program using for loops t

Write a program using for loops to produce the following output. Please read carefully the entire specification!

  Accept positive and negative numbers in its input sequence

the program must accept positive and negative numbers in its input sequence, and ?nd the largest and smallestof the numbers entered whether they are all positive, all negative, or a combination of both positive and negative.

  Write c program to accept inputs from user

Write down simple c program which accepts following inputs from user that is username and password, it must ask user what he will like to learn today and also ask user to enter char m=math , e= English.

  Demonstrate overriding of their getter and setter methods

Organize following animals using classes and virtual function. tigers,crocodile, elephants,pythons,zebras,hawks, chickens,rabbits using at least 3 properties some of the animals share. demonstrate overriding of their getter and setter methods.

  Same birthday

How likely is it that two people in one section of our class (40 students) have the same birthday ?

  Stores a series of numbers in a binary tree.

Queue Converter, Write a program that stores a series of numbers in a binary tree. Then have the program insert the values into a queue in ascending order. Dequeue the values and display them on the screen to confirm that they were stored in the prop..

  Define a class for a type called fraction

Define a class for a type called Fraction. This class is used to represent a ratio of two integers. Include mutator functions that allow the user to set the numerator and the denominator.

  Use numbers 0 through 23 to represent hours

Write a C function seconds_since_jan1() that takes the time as six integer arguments (year, month, day, hour,minute, and second) and returns the number of seconds since the beginning of the year. Use numbers 1 through 12 to represent months. Use numb..

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