What is the output of the following program when it is executed 3 separate times with the Inputs 5, 3, and 2? 1 #include 2 3 int mainO { int choice; scanf("%d", &choice); int total 4 0; %3D switch(choice) { case 1: total 8. 9. total + 3; %3D
Q: 2. Consider the following code fragment. char ch; cin >> ch; switch (ch) { case 'a': cout << "*\n";…
A: Actually, program is an executable software that runs on a computer.
Q: Question 16 What is output by the code below? for x in range(4): print(x, end = " " } 0 4 O 4 4 4 4…
A: Answer: 0 1 2 3
Q: When the following program is executed, it terminates with an error. Which option best describes the…
A: Coded using Python 3. As per the guidelines we are supposed to answer single question so I am…
Q: There are N stairs, and a person standing at the bottom wants to reach the top. The person can climb…
A: Write a C++ program to read the value of integer N from the user and print the number of ways to…
Q: What is the output for the following program below Sub Main () Dim i, sumodd, sumeven As Integer For…
A: The above code add the ith value repeatedly to the sumodd and sumeven variable If i value is odd,…
Q: 1. Consider the following code fragment. int x; cin >> x; switch (x + 3) { case 5: cout <<x << '\n';…
A: In this case switch statement take x+3 and then compare with the condition. if x+3 is 5 then print x…
Q: a. Line 1 for (int i=n-1; i<=n; i++) { f(n) = O( Line 2 for (int j=1; j<=n; j=j*2) { Critical…
A: Given: Given Java question, we need to fill in the blanks.
Q: What is the value stored in X[4] after the following code segment is executed? int X[5] = {5, 13,…
A: We are given a piece of code in C++ and we need to find the value of X[4] after execution of the…
Q: In the following program, explain the relationship between the outputs on line 8 and 9: class…
A: The output of line 8 and 9 comparison:
Q: what is the output of the following code? X = [12 3;4 5 6;7 8 9];Y = [9 8 7;6 5 4;3 (2 1]; r=…
A: Let's first understand what is the code is all about . First we have the matrix x = 1 2 3…
Q: ne output from the following segment of screen, int f 1(); void f_2(int = 3); float f_3(int &); zint…
A: Ans -- The code's output after the compilation gives ::
Q: 3. Write a program that takes one argument, a positive integer n, and prints the product 1*2*..*n.…
A: Step 1: Check whether the number of command-line arguments not equals to 2. Step 2: If the condition…
Q: Program32.java Write a program that prompts the user for any day of the week. Report the entered day…
A: The solution to the given problem is below. ***Note: According to Bartleby policy we are not…
Q: What is the output for the following program? #include void main( ) Answer: { int sum, f= 10, d =…
A: #include <stdio.h>int main(){ int sum,f=10,d=20,i = 5, j=3; sum = f+i; if(sum…
Q: Read the following program and identify the output of the progran int tmain(int argc, _TCHAR*…
A: -- operator decrements value by 1. and ++ operator increments value by 1.
Q: What will be the value of the variable z after execution of the following code? int n[10] = { 3, 5,…
A: Given code: int n[10]={3,5,2,11,4,15,2,7,3,1}; int k=3; int z=3; void setup() { switch(k){ case 0:…
Q: Consider the following declaration: int[][] beta new int[3][3]; What is stored in beta after each of…
A: Given that, int[][] beta=new int [3][3]; That means beta is a two dimensional array which contains…
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: In the given program, an array of size 7 is defined which contains 6 elements. Then, a variable ss…
Q: Q4)What will be the output for this code(Explain your logic with help of dry running for the same)…
A: The output will be 101. This program contains a main function and another function named foo. foo…
Q: what is the output of the following code? Static linearqueue q. int a ] = {1, 3, 5, 7,9, 11, 13, 15,…
A: Queue is a data structure which follows the FIFO (first in, first out) principle. Enqueue always…
Q: What is the output of the following code? (NOTE: There are nos output) void test () static int x =…
A: This program about c++ ( when count= 1)x=0+2 (when count =2)x=2+2 (when count =1)y=1+1 (when…
Q: What is the output of the following expression? def add(x, y=10): **"Return x plus y, optional"**…
A: Default Parameters: Parameters are exist at called function. Parameters are accept the values of…
Q: What is z after the following switch statement is executed? int i = 10; int z = -1; switch (i) {…
A: In the following given question, We have to find the value of z after the switch statement get…
Q: What is the output of the following code when embedded in a complete C++ int secret (int x) { } int…
A: #include <iostream>using namespace std;int secret(int x) // function prototype{ int i=2*x,…
Q: What are the possible outputs when the following program is run? 1 int main(void) { 2 int stuff = 5;…
A: The given program includes the fork function which is used to create a new process. The fork…
Q: What is the output after executing the following code? int a 8; int b = 9, x; double c; a/b + 2; %3D…
A: Java program: public class HelloWorld{ public static void main(String []args){…
Q: 1. Consider the following code fragment. int x; cin >> x; switch (x+ 3) { case 5: cout <<x << '\n';…
A: Given the following code fragments what is printed when the user enter a number.
Q: b) Show the output of the following code fragment. Then change this if-else-if codes to the switch…
A: #include <iostream>#include<math.h>using namespace std;int main() { double a,t; int…
Q: What does the following program do? What happens if you exchange lines 5 and 6? 1. #include 2. int…
A: In this question, a piece of code is given in C language
Q: Read the following program and Identify the output of the program int _tmain(int argc, _TCHAR*…
A: We need to find the correct output for the given C++ program.
Q: How many times "Testing" statement is printed in the following code? Public static void…
A: I have provided the answer based on Java Programming. Detailed comments are included for a better…
Q: 2. Consider the following code fragment. char ch; cin >> ch; switch (ch) { case 'a': cout << "*\n";…
A: Given a c++ program, contains switch case statements. If the user enters a value, then that…
Q: Program31.java Write a program that prompts the user to enter an even multiple of 17 between 200 and…
A: Solution: Given, Program31.java Write a program that prompts the user to enter an even multiple…
Q: Question 2 What is the output of the following code? public static void main (String [] args) ( int…
A: //analysing code for output public static void main(String[] args) { int a=4,b=6; //value…
Q: What is the output of the following code? int x = 6; int tempX = 0; do { switch (x) { case…
A: Switch case is an alternative for if else structure and do while runs the loop for 1 or more time…
Q: What is z after the following switch statement is executed? int i 1; int z = -1; switch (i-1) { case…
A: Given data:-
Q: What is the output of the following program lines when they are embedded in a correct program that…
A: A data type can be understood as an property of data that instructs the compiler or interpreter how…
Q: What is the output of the following code? int x = 0; if (x > 4) { x = x + 1; } System.out.println…
A: The output of the code
Q: Read the following program and identify the output of the program. int_tmain(int argc, _TCHAR*…
A: The correct option is - a. 5,4,1 Explanation: _tmain() and _TCHAR are non-standard extensions.…
Q: In the following code stream, identify if there are any hazards. Crisply describe if it is possible…
A: About hazards: Structural hazards: it means that hardware cannot support the combination of…
Q: Java code Ever wondered how change is disbursed to customers in certain stores? In country X the…
A:
Q: Q2 / Read the following code carefully, and then program the same idea using if-else-if ladder.…
A: Using if-else if ladder if one of the condition executes true, then it doesn't even checks for the…
Q: When the following program is executed, it terminates with an error. Which option best describes the…
A: Wrong options are : a. The function will terminate the program due to invalid syntax. b. The…
Q: Q2: What is the output of the following statements: ماهي نتائح كتفير الخطوات التالية int a,b,k,…
A: //Tracing code for output int a,b,k,x=1,y=2; cout<<"a b"<<endl;//prints a…
Q: What will be the output of the following program? #include int main() { int x = 1; switch (x) {…
A: Program #include<stdio.h>int main (){ int x = 1; switch (x) case 1: printf("choice…
Q: There are N stairs, and a person standing at the bottom wants to reach the top. The person can climb…
A: Here we are given the number of stairs and we need to find the number of ways to reach the top, and…
Q: What is the value of the variable ss after the following code is executed? int x[ 7 ] =…
A: The C++ for loop is used to iterate a part of the program several times
Q: What will be the output when the following code segment is executed? public static void main(String…
A: output will be: before function call a, b, x, y are 3 2 0 5 after…
c language
Step by step
Solved in 4 steps with 3 images
- In C++ 2.12 LAB: Hypotenuse Given two numbers that represent the lengths of a right triangle's legs (sides adjacent to the right angle), output the length of the third side (i.e. hypotenuse) with two digits after the decimal point. Output each floating-point value with two digits after the decimal point, which can be achieved by executingcout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 3.0 4.0 the output is: Hypotenuse: 5.00Modify the following C code to get the given output: #include <pthread.h> #include <semaphore.h> #include <stdio.h> /* This program provides a possible solution using mutex and semaphore. use 5 Fsrmers and 5 ShopOwner to demonstrate the solution. */ #define MaxCrops 5 // Maximum crops a Farmer can produce or a Shpoowner can take #define warehouseSize 5 // Size of the warehouse sem_t empty; sem_t full; int in = 0; int out = 0; char crops[warehouseSize]={'R','W','P','S','M'};//indicatig room for different crops char warehouse[warehouseSize]={'N','N','N','N','N'};//initially all the room is empty pthread_mutex_t mutex; void *Farmer(void *far) { /* 1.Farmer harvest crops and put them in perticular room. For example, room 0 for Rice(R). 2.use mutex and semaphore for critical section. 3.print which farmer is keeping which crops in which room inside the critical section. 4.print the whole warehouse buffer outside of the critical section */ }…Your cousin owns an automotive maintenance shop that performs routine maintenance on cars. He has asked you to write a program that will provide a list of services (and their respective prices) to users and allow them to choose any, or all, services they would like and display the final price, including a 34% labor charge, a 14% markup if the car is an import, a 4% Covid-19 Sanitizing fee, and an 9.5% sales tax. Task To accomplish the above, do the following: • Write the two methods outlined below. • Test your program and screenshot your successful test. carMaintenance method This method should accept the make of the car as a parameter (e.g., BMW, Ford, Ferrari, etc.). It should display the services and their prices as follows: Services: Emissions System Repair, Tune Up, Timing Belt Replacement, Transmission Service, respectively: 669.99, 259.99, 885.99, 169.99 These should be stored in parallel arrays. Ask the user to select a service from the list presented for his . Allow the user…
- 5.A)For the code segment below, what should be the values for q will result in kiwi being included in the output? switch(q) { case 1: cout << "apple"; break; case 2: cout << "orange"; break; case 3: cout << "banana"; break; case 4: cout << "pear"; case 5: cout << "grapes"; default: cout << "kiwi"; } B)Evaluate the following segment of a program. Show the procedure to reach your answer. int a = 3, b = 5, c = 2, d = 4; find: !(a / b > 0) && (22 > b % c + d) || !(a * d >= b – d / c) C) Write equivalent expressions for each of the following by using De Morgan’s Law. !(c == ‘r’ || (( y > 2) && !found ))1. The following statements shown below will result in the printing of: for (i= 3; i < 15; i += 3) { printf ("%d ", i); ++i; } 2. Complete the following code segments below to display this output. Replace ??? with your answer. 11111 2222 333 44 5 for (int j = 1; j = j; k--) { ???; } printf("\n"); } 3. How many times does the program below prints an *? for (int i = 5; iWhat is the set st4 created by the following Python statements? st1 = set(range(0, 16, 2)) st2 = set(range(0, 16, 3)) st3 = set(range(0, 16, 5)) st4 = st1.intersection(st2, st3) Lütfen birini seçin: a. {6, 12} b. {0} c. {0, 2, 3, 5, 6, 8, 9, 10, 12, 14, 15, 16} d. None of the others e. {0, 6, 12} pls help me =)
- In each of the following code snippets, data is copied from x to y. How many bytes of data arecopied? The answer should be a C expression. (e) int x=10, y=x;(f) int x[10]; int *y = x;(g) int x[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; void f(int y[5]) { ... } int main() { f(x); }(h) int x[10], y[10]; ... memcpy(y, x, 5*sizeof(int));python Write a program that does temperature converter", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)5/9 $.\n", "\n", "Print the converted temperature and show the unit, like 23.5 C or 67.1 F."I want the code in C++. 7.10: Tic Tac Toe (sort of) Write a program that will allow two users to play tic-tac-toe. The program should ask for moves alternately from player X and player O. The program displays the game positions as follows: 123 456 789 The players enter their moves by entering the position number (a single digit, 1-9) they wish to mark. After each move, the program re-displays the changed board. A sample board configuration is as follows: XXO 456 O89 SAMPLE RUN #1: ./ETest Interactive Session 1 2 3 4 5 6 7 8 9 Enter move:1 X 2 3 4 5 6 7 8 9 Enter move:2 X O 3 4 5 6 7 8 9 Enter move:3 X O X 4 5 6 7 8 9 Enter move:4 X O X O 5 6 7 8 9 Enter move:5 X O X O X 6 7 8 9 Enter move:6 X O X O X O 7 8 9 Enter move:7 X O X O X O X 8 9 Enter move:8 X O X O X O X O 9 Enter move:9 X O X O X O X O X Game over!
- write a c code for this code While travelling in a train, you observe some college students pulling the alarm chain simply to get down at their desired point. Out of n students m<=n times students pull the chain .You have to print according to the following: 1) If m is >=80 % of n then print strict action is required to restrict this event 2) If m is between 50 to 80 % then print guidelines should be issued 3) If between 10 to 50% then print request to restrict the event 4) If less than 10% then print No action required write flowchart and algorithm for this code.The steelwork.py program, given below, creates three types of steel objects. Carbon steel (Steel) is made of carbon and iron, alloy steel (AlloySteel) contains chromium in addition to carbon and iron. Stainless steel (StainlessSteel) contains nickel and a higher proportion of chromium. Write the missing code, in the designated locations (#TODO), in order for the program execution to yield the following output: ['Steel01', 0.6, 91] ['ALSteel02', 0.6, 91, 1] ['SSteel02', 0.6, 91, 11, 2]Programming Practice a) Write a program which allows a teacher to determine the min, max, and average grade from grades entered. The teacher will continuously enter grades until the sentinel is specified. For this example, a grade of -1 will be used to denote grading is completed. The min, max, and average grade should then be displayed to the teacher. This program should not accept invalid grades to be used [0, 100]. b) Write a program which outputs prime numbers up to a specified number. For example, if a user entered the number 25, the program would output the prime numbers between 1 and 25. c) Write a program which converts a sum of currency into the highest available denominations in terms of coins. For example, the user inputs the number 4.25. The program would output that it takes 2 Toonies and 1 Quarter. Ensure that the result uses the least amount of coins possible. This can be solved mathematically or using loops.