x = 2, y =1, z =3, what is the value of x, y, z after executing the following codes? switch(x) { case 0: x =2; y =3; case 1: x =3; break; default: x=3; y=2; }
Q: Rewrite the following code segment using if-else statement instead of switch statement: switch (i) {…
A: 1)Code: using if else: //rewriting of the code using if else statements instead of switch statement…
Q: This code display the value of roots in text boxes for the following quadratic equation using…
A: Solution any equation which contains an unknown term and not a higher power term any equation…
Q: program Credit Card Validator - Takes in a credit card number from a common credit card vendor…
A: program in C++
Q: if (x + y> z) return ceil (y), floor (x); else return ceil (z + x) * y: return x + y + z; What is…
A:
Q: The else statement doesn't have a conditional expression. True False You can only have one case…
A: All the above questions are related to control flow statements. Control flow statements are used to…
Q: Write a program using if statement instead of switch statement. x=2; switch x case 1; disp(‘One’)…
A: The program is written using the switch case statement. We can write it in the if, else and else if…
Q: Q2- Write a program to find the value of A (use switch statement): A=x+b when k=1 A=x-b when k=2…
A: NOTE: Programming language is not mentioned so doing in C++ In this question, we are asked to write…
Q: What is printed when the following code executes and x equals 4 and y equals 3? if (!(x 2))…
A: second case
Q: Q1) Complete the following program c++ by writing a switch statement that displays “one” if the user…
A: Answer: #include<iostream>using namespace std;int main(){ int userNum; cout<<"Enter one…
Q: What is the value of y when the following switch statement is executed? int x-3, y; Switch (x + 3) (…
A: Switch case: The switch statemnt is defined as checking each and every variable whether it is equal…
Q: Q/The equivalent statements for the following code are for(i=4;i>=0; i--) switch (i) {case 0:…
A: The correct answer is There is no right choice. The given code has few missing elements which does…
Q: You can always convert a multi-way if-else statement to an equivalent switch statement. True False
A: We can only use: integers or characters in case statement of switch statement. So we can not use…
Q: Write a program using an if statement instead of a switch statement. x = 2; Switch x case 1; Dis…
A: #include<stdio.h>int main(){ int x=2; if(x==1){ printf("the one"); } else if(x==2){…
Q: Write a program that asks the user to enter a number within the range of 1 through 10. Use a switch…
A: Switch statement : A switch statement allows a variable to be tested for equality against a list of…
Q: You can have an else statement without an if statement. O True O False You can set and specify a…
A: 1)False We can not have an else statement without if. however, we can use only if without else…
Q: Write a switch statement that displays Sunday, Monday, Tuesday, Wednesday, Thursday, Friday,…
A: Switch case is used when there is repetitive coding by improving quality. Program is written in Java…
Q: Suppose that classStanding is a char variable, gpa and dues are double variables. Write a switch…
A: Program: //include the header file #include <iostream> using namespace std; //definition…
Q: This code prints the odd numbers from 1 to 20 and the number of odd numbers. Private Sub…
A: We need to find the correct option regarding the given VB code.
Q: Write pseudo code and design flowchart that will count all the count all the even numbers up to a…
A: Flow chart: It is used to represent program steps in the pictorial representation. Using the flow…
Q: double x = -3.5, y = 3.5; cout<<ceil (x)<<" : "<<ceil(y) <<endl; cout<<floor (x)<<" : "<< floor (y)…
A: ceil function: ceil function give the next greater than integer. floor function: floor function…
Q: int main() { if(var1>50) { num = 20.0 } else { if(var1>35) ---- Line 7 { num= 35.0; }…
A: Given: In order for the value of num to equal 60.0, what should the result of the condition in line…
Q: code
A: Introduction Java is basically a type of programming language that is very much beneficial and can…
Q: What does the following code display? char ch 'y'; switch (ch) { case 'a': case 'b': case 'c':…
A: Answer : End When you pass ch = y it will goes into switch case y and there it will print End.
Q: int x = 2; while(true){ switch (x) { case 4: x += 6; break; case 9: x *= 3; break; default: x++; }…
A: Please find the answer below :
Q: Which of the following switch statements is equivalent to this if statements int x = 10; %3D if(x <…
A: Given:-
Q: int x = 5, y = 10; switch(x>y && x+y>0) { case 1: printf('hi"); break; case 0: printf("bye"); break;…
A: 1) Above program defines variable x = 5 and y = 10 2) In Switch statement it evaluates expression…
Q: 2. Write a code that accepts a number from the user using input command and display the word "…
A: Note : since programming language is not mention we are providing solution in PYTHON programming.
Q: The following code reads x, and if it is divisible by 5 and positive then it should print "x is…
A: The instructions are provided by the programmer according to the requirement using the programming…
Q: In C, the condition that will give a true statement when a number x is in the range of is 0 10 O x>0…
A:
Q: Given x = 4; and y = 2; and operator = '-' ; what is the final value of x after the following switch…
A: When x=4, y=2, and operator='-' Then, final value of x is (4-2)= 2.
Q: The default block can be placed at the end of the switch. O True False
A: Default statement: Default statement will execute if no case constant-expression value is equal to…
Q: (c programming) Write a program using switch to input a letter (L) and and number of cars(C). The…
A: Program using switch to input a letter (L) and and number of cars(C) is below with commented…
Q: What is the output of the following, if n=1, n=2, n=3, n=4, and n=5, respectively? int n =…
A: for n=1 it will print less than 3 for n=2 it will print less than 3 for n=3 it will print less…
Q: What is y after the following switch statement is executed? int x = 1; int y = 3; switch (x-1) {…
A: int x = 1; int y = 3; switch (x-1) { case 1: y = 1; break;…
Q: You are writing code which asks the user to input a number and prints "odd" if it is odd, and "even"…
A: You are writing code which asks the user to input a number and prints "odd" if it is odd, and "even"…
Q: You can always convert a switch statement to an equivalent multi-way if-else statement. O True O…
A: A switch is branching statement which is used to alter the flow of control based on evaluated…
Q: Using the C++ Switch Statement, write a program that will calculate a person's pay based on the…
A: //Code in C++ #include<iostream>#include<iomanip>using namespace std; int main() {int…
Q: if (a > 0) if (b 5) x - x + 4; else x - x + 3; else x -x + 2; « is currently 0, a is 1 and b is -1,…
A: Here in this question we have given a Java code and we have asked to find the final value of x after…
Q: ! This code prints the odd numbers from 1 to 20 and the number of odd numbers. Private Sub…
A: The given program is related to VBA or Visual Basic for Application. VBA programming is a little bit…
Q: A switch statement can only have one default case. O True O False The value of switch case…
A: The default statement doesn't have to come at the end. It may appear anywhere in the body of the…
Q: 7) Change this switch statement to if-else ladder int x = 20; switch (x) { case 10: cout<<"X is 10";…
A: Change the above switch-case into if-else: int x = 20; if (x == 10) { cout <<…
Q: Q2- Write a program to find the value of A (use switch statement): A-x+b when k-1 A-x-b when k-2…
A: As no programming language is mentioned it is solved using basic C++
Q: Write a selection statements to to check whether the values of two variables i and j are divisible…
A: selection statement selects among a set of statements depending on the value of a controlling…
Q: Which value can be entered to cause the following code segment to display the message: That number…
A: PROGRAM: #Getting input from the user number=int(input()) #Checking the number value between the…
Q: a) A local shop sells festival cookies at RM28.50 per box. The shop offers special discount for…
A: As per the requirement program is written. Algorithm: Step 1: Write the main() method Step 2: Print…
Q: a) Rewrite the following code segment in C++ switch statement: if (grade >='A' && grade <= 'C') cout…
A: code snippet:
Q: A sales event at Trader Jane's is reducing some items by 25%. Store that value to a properly named…
A: Since you are not mentioning the programming language, here we are using Python to complete the…
Q: Given x = 4; and y = 2; and operator = -' what is the final value of x after the following switch…
A: A switch is a control expression that allows one to choose one option from a list of options.…
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
- x = 2, y =1, z =3, what is the value of y after executing the following codes? switch(x) { case 0: x =2; y =3; case 1: x =3; break; default: x=3; y=2; } A) 1 B) 2 C) 3 D) 4If originally x = 4, y = 0, and z = 2, which is the value of x, y and z after executing the following code? if ( z == 2) y = 1; else x = 3;Given x = 4; and y = 2; and operator = '-' ; 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 ; also, using x = 4 ; and y = 2 ; and operator = ' * '. What is the final value of x? }
- A sales event at Trader Jane's is reducing some items by 25%. Store that value to a properly named constant. Write a program that functions like a cashier terminal for one item. Some items are subject to 7% sales tax and some are not. Use a constant for the sales tax value, too. Write a program for Trader Jane's that runs as shown next: Enter the ticket price of the item 100 Is this item reduced y/n? y is this item taxable y/n? y Here is your bill Original price $100 Reduction during event $25.00 Final price $75.00 7% Sales tax $5.25 Total amount due $80.25What is the value of the expression 10 + t1%t2*5/(t3-1)? Assume that, int t1=17, t2=3, t3=7;Using C#, write a console based application that takes one integer from user’s input and calculate the number of 0 contained in the factorial. For example, if users’ input is 10, then the factorial of 10 is 5!=10*9*8*7*6*5*4*3*2*1 = 3628800 So, the number of 0s is 2.
- Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print "Beta". For any other character, print "Unknown". Use fall-through as appropriate. End with newline. #include <iostream>using namespace std; int main() { char origLetter; cin >> origLetter; /* Your solution goes here */ return 0;}What is the output of the following C11 code?int x = 15;int y = 3;if (x + y > 17 || y - x < 20){y = x - y;x = y + x;cout << x << " " << y << " " << x + y << " " << y - x << endl;}else{x = y - x + y %5;cout << x << " " << y << " " << x - y << " " << x + y << endl;}Write a code snippet that prompts the user for an integer named number and prints out “Good Number” if the input meets any one the following conditions, and prints out “Bad Number” if it does not : number equals 5 number equals 7 number is between 10 and 20 (non-inclusive) number is greater than 30.
- Correct the following code so that it prints the correct message. (3)if (score <= 60)cout << "Pass" << endl;else;cout << "Fail" << endl; 16.What is the output of the following C++code? (2, 5, 6)int x = 15; int y = 3; if (x + y > {y = x -x = y +cout << x << " " << y << " " << x + y << " " << y - x << endl;}else{x = y - x + y %5;cout << x << " " << y << " " << x - y << " " << x + y << endl; } 21.Suppose that score is an int variable. Consider the following ifstatements. (3)if (score >= 90);cout << "Discount = 10%" << endl;a. What is the output if the value of score is 95? Justify your answer.b. What is the output if the value of score is 85? Justify your answer. 22.Suppose that score is an int variable. Consider the following ifstatements. (3)i. if (score == 70)cout << "Grade is C." << endl;ii. if (score = 70)cout << "Grade is C."…Fox International sells pre-paid calling card with the following features: Calls to USo 1.2 cents per minute plus a 49 cent connection fee per call Calls to Europeo 2.3 cents per minute plus a 49 cent connection fee per call Calls to Australiao 6.4 cents per minutes plus a 49 cent connection fee per callWrite a program that work out the charges for the month. The program should accept the followinginformation: Account holders name Card number Starting Balance on card For US callso Total number of minutes of all callso Total number of calls made For European callso Total number of minutes of all callso Total number of calls made For Australian callso Total number of minutes of all callso Total number of calls madeYou are NOT expected to error check your inputs for this assignment. (e.g. checking for negative values,etc.). There is NO GST charged on the calls as the GST was paid when the card was purchased.Format of output:Review the test plan to see how the user would like the…Look at the code below and provide testcases for 100% statement, branch and condition coverage- Give 10 test cases ref to Facebook functionality by solving above problems. def compute(x,y,z): if (x>2 or y >0) and z=1): x+y-z else: x-y+z