
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
What is y after the following switch statement is executed? int x = 1; int y = 3; switch (x-1) { case 1: y = 1; break; case 2: y = 2; break; default: y += 0; }
1
3
2
0
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- // Program gets a quantity ordered from user // then determines price and discount based on quantity // price per item before discounts is $6.00 // order 15 or more, get a 20% discount // order 10 to 14 - get a 14% discount // order 5 to 9, get a 10% discount using System; using static System.Console; using System.Globalization; class DebugSeven3 { static void Main() { int quantity; double price; quantity = GetQuantity(); price = CalculatePrice(int quantity); WriteLine("Final price for {0} items is {1}.", quantity, price.ToString("C", CultureInfo.GetCultureInfo("en-US"))); } private static int GetQuantity() { int quan; WriteLine("Enter number of items >> "); quan = Convert.ToInt32(ReadLine()); return quan; } private double CalculatePrice(int quantityOrdered) { double PRICE_PER_ITEM = 6.00; double price = 0; double discount = 0; int[] quanLimits = {0, 5, 10, 15}; double[] limits =…arrow_forwardObserve the following switch statement closely: switch (prompt("What is your mood today?")) { case "happy!": console.log("Yay!"); break; case "Sad".toLowerCase(): console.log("Don't be sad..."); case "upset": console.log("Get glad!"); break;case "UNKNOWN":console.log("How do you not know?"); default: console.log("Are you human?"); break; } MC 3a If input is "happy!", then output is: a) "Yay!" b) "How do you not know?""Are you human?" c) "Are you not human?" d) "Get glad!" MC 3b If input is "Sad", then output is: a) "Get glad!" b) "Don't be sad..." "Get glad!" c) "Are you human?" d) None of the above MC 3c If the input is "UNKNOWN", then the output is: a) "How do you not know?" "Are you human?" b) "How do you not know?" c) "Are you human?" d) None of the abovearrow_forwardC++arrow_forward
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forwardswitch (i){case 1:printf(" Case1 "); break;case 2:printf(" Case2 "); break;case 3:printf(" Case3 "); break;case 4:printf(" Case4 "); break;default:printf(" Default ");arrow_forwardSuppose a byte-addressable computer using set associative cache has 8M byes of main memory and a cache of 128 blocks, where each cache block contains 64 bytes. a) If this cache is 4-way set associative, what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, set, and offset fields? b) If this cache is 16-way set associative, what is the format of a memory address as seen by the cachearrow_forward
- Rewrite the following code segment using the conditional operators (?/:) if (x > y) Z = 1; else z = 20;arrow_forwardAfter a certain point, the usage of an initial block statement becomes invalid.arrow_forwardWhat will the value of myVar be after the following statements are executed? int myVar = 10;myVar = 21 / 4;switch (myVar){ case 4: myVar += 5; break; case 5: myVar -= 3; break; default: myVar *= 3;}arrow_forward
- Given x = 4; and y = 2; and operator = " ; %3D %3D what is the final value of x after the following switch statement is executed? switch (operator) { case '+': x +=y; break; case - : x-= y; break; X += y; is x = x + y ; case *' : x *= y; break; case '/' : x/= y; break; default : break; Similarly to question in number 2, using X = 4 ; and y = 2; and operator ='*'. %3D What is the final value of x?arrow_forward#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education