Question

4. (20 points + 10 point bonus) What data types are allowed in the test expression of a switch and what kinds of values can b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

The data types allowed in the test expression of a switch statement are int, char and enum, use of any other data type is not allowed.

The case expression of can have only constant values and it must also be noted that two case expressions cannot have same value. i.e 2 and 1+1 are same and they cannot be used in two different cases inside a switch.

Why floats and doubles are not allowed in the test expression of a switch statement, for this you must note that a switch statement requires a exact value, but floats like (1.2)  are stored in the memory as approximations that is they are not exact, due to the limitation of the binary number system.

Hope it answers your question :)  

Add a comment
Know the answer?
Add Answer to:
4. (20 points + 10 point bonus) What data types are allowed in the test expression...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Quiz Question 1 (1 point) Saved The maximum value for an int is: Question 1 options:...

    Quiz Question 1 (1 point) Saved The maximum value for an int is: Question 1 options: 2147483647 65535 32767 9223372036854775804 Question 2 (1 point) A float has ____ decimal places of accuracy. Question 2 options: 15 none     7 3 Question 3 (1 point) It is a good practice to compare floats and doubles with ==. Question 3 options: True False Question 4 (1 point) Strings are reference data types. Question 4 options: True False Question 5 (1 point) Value data...

  • Part Two: Fill in the Blanks and True/False (24 total points - 2 points each) For...

    Part Two: Fill in the Blanks and True/False (24 total points - 2 points each) For each of the following, fill in the most appropriate word(s)phrase/solution in each blank 1) Keywords, identifiers and literals are all kinds of are simply groups of characters that are used for various purposes in a program. , which 2) The Java expression: 11 - 2 + 3 evaluates to 3) List the Java boolean (logical) operators in order from highest priority to lowest priority...

  • Bonus (5 points) Suppose that you are testing the following hypotheses: Ho: 4 = 10 and...

    Bonus (5 points) Suppose that you are testing the following hypotheses: Ho: 4 = 10 and H :> 10. If the null hypothesis is rejected at the 1% level of significance, what statement can you make about the confidence interval on the mean? a) The lower bound of a 95% one-sided confidence interval on the mean exceeds 10. b) 9 <u< 13 c) No statement can be made. d) The lower bound of a 95% one-sided confidence interval on the...

  • Take Test: CH 4 Exam Test Information Description Instructions Multiple Attempts Not allowed. This test can...

    Take Test: CH 4 Exam Test Information Description Instructions Multiple Attempts Not allowed. This test can only be taken once. Force Completion This test can be saved and resumed later. Question Completion Status: Close Window Δ Moving to another question will save this response. Question S of 20 ) » Question 5 2 points Save Answer You have a score of X 75 on a math exam. The mean score for the class on the exam is μ = 85,...

  • need help whats the answers numItems and userVal are int types. What is the final value...

    need help whats the answers numItems and userVal are int types. What is the final value of numItems if userval=3? switch (userval) { case 1: numItems - 5; break; case 3: numItems - 12; break; case 4: num Items - 99 break; default numItems - 55; break; } O 12 55 5 99 istall, isRich, and isFamous are Boolean variables. What is isFamous after executing the following statements? istall - false; Rich = true; inFamous - false; sf (istall &&...

  • QUESTION 1 What will be displayed as a result of executing the following code? int   x...

    QUESTION 1 What will be displayed as a result of executing the following code? int   x = 5, y = 20; x += 32; y /= 4; cout <<"x = " << x <<"y = " << y; A. x = 32, y = 4 B. x = 9, y = 52 C. x = 37, y = 5 D. x = 160, y = 80 8 points    QUESTION 2 What will be the displayed when the following code...

  • show all the work Suppose that a sample of 20 pairs of data produced a test...

    show all the work Suppose that a sample of 20 pairs of data produced a test statistic of r = 0.515. A significance level of a = 0.05 is to be used. (a) Find the critical values that would be used to test for significant linear correlation. Do not type "+" in front of your answer (the is already given in front of the answer box below). Round your answer to 3 places after the decimal point, if necessary. 0.9-...

  • Q4.1 OPTION A 10 Points Compute tan sin Note: Your answer will be an expression in...

    Q4.1 OPTION A 10 Points Compute tan sin Note: Your answer will be an expression in terms of x. "Magic formulas" not taught in this class are not allowed for this problem. Please select file(s) Select file(s) Q4.2 OPTION B 10 Points Let a and ß be two acute angles in Quadrant I such that 5 tan(a) = and 12 sec(B) = 17 8 Calculate sin(a - 28). i) Find the amplitude, period, phase shift, and midline of the trigonometric...

  • Use Random number generator (under Data Analysis) to create THREE columns of data each 20 points...

    Use Random number generator (under Data Analysis) to create THREE columns of data each 20 points long. -For the FIRST data set use the following parameters: number of variables (2), number of data point (20), Distribution (Normal), Mean (20), Standard Deviation (5), Random seed (1234). Keep these data in columns labeled A and B. -For the SECOND data set use the following parameters: number of variables (1), number of data point (20), Distribution (Normal), Mean (30), Standard Deviation (5), Random...

  • Take Test:CH 4 Exam Test Information Description Instructions Multiple Attempts Not allowed. This test can only...

    Take Test:CH 4 Exam Test Information Description Instructions Multiple Attempts Not allowed. This test can only be taken once. Force Completion This test can be saved and resumed later Question Completion Status: Close Window Δ Moving to another question will save this response. « < Question 6 of 20 > Question 6 2 pointsSave Answer A population of scores has μ-100 and σ 25. If every score in the population is multiplied by 2, then what are the new values...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT