Use a trace table to show what is the output of the following program. Then compile and run the program and compare the results to your trace table. #include <isotream> main() { int i, j = 9; for ( i=2; (i<=17) && (j>1); i=i*2) { j = j-3; cout << i << " " << j << endl; } }
Q: Write a program in C++ that lets the user input an odd number of positive integers (space separated)…
A: Logic:- First take input from user , the number of elements and all elements. Apply check if n is…
Q: Use the Design Recipe to write a function weighted_total(number_list,weights) that consumes a list…
A: The given list of numbers is [1, 2, 3].The given weights are [0.1, 0.5,…
Q: Write a Phyton program which counts the number of the five main vowels in a string and prints the…
A: To get the count of each vowel, iterate over the string and count the occurrence of each vowel…
Q: Write a program that will take input 3 int numbers as input from user in main and pass all numbers…
A: Note: We are authorized to answer one question at a time, since you have not mentioned which…
Q: Find the contents of AL, BL and CL after execution of the following program MOV AL, 76h DEC AL MOV…
A: MOV AL,76H - Transfer 76H into register AL.DEC AL -…
Q: Consider the following code (and assume that it is embedded in a complete and correct program and…
A: Given: Consider the following code (and assume that it is embedded in a complete and correct program…
Q: Consider the function definition below. Assume x = 5, y = void findout (int &x, int y, int &j) { }…
A: Let us see the answer below.
Q: Q2 - Write a program by FORTRAN90 language to find the value of 'y'from the following equations: 3…
A: Step 1:- Program Approach:- 1.Declare the variable x and y as real data type 2.Take the input…
Q: 2. Write a complete C program with the implementation of functions to generate multiplication table…
A: #include <iostream>using namespace std; void printTable(int num){ for(int i=1 ; i <= 12…
Q: Write a program in C that does the following. The program starts by offering the user the following…
A: // C program for the implementation of // menu driven program for student // management system…
Q: How would you go about analyzing what the following code does?
A: #include <iostream> using namespace std; int main(){ int num = 0, count = 0, sum = 0;…
Q: Your task is to trace execution of the following Python function: def ends (phrase) : new word =…
A: Below is the table to trace the execution of the function:
Q: Suppose the following code is given(division (/) is integer division) int update(int *p) { *p=*p+2;…
A: - We have to talk about the code regarding devision. - The code :: int update(int *p){ *p=*p+2;…
Q: The language we are using here is in Racket. Please enter the following code: (cond ((equal? 16…
A: 1) The return value of above code is 18. 2) When we replace all the 16s in the above code with 8 the…
Q: Translate the following C program into NASM. #include int ary[] = {12, 40, -2, 89, 35, -7, 6};…
A: Given C program : #include <stdio.h> int ary[] = {12, 40, -2, 89, 35, -7, 6}; int main() {…
Q: Write output of the following c++ code by completing it with explanation of all iterations Need…
A: Program Approach: Include header files. Using namespace. Declaring methods fun1 with integer type…
Q: Given the code below, assume that all the fork/pipe operations succeed, and neglect any syntax…
A: Answer is given below-
Q: The code is already given above. Problem: Using PYTHON, create a code that asks you to enter three…
A: Given: Given a python coding problem.
Q: According to the assignment rule, what should be the precondition in the following program…
A: Given: x = x - 2 x = y
Q: a. Convert the following code segment as follow: -Do while loop → to be converted to → Do Loop Until…
A: Do while is a loop in vb which continue iterating statements as long as condition is true. In case…
Q: Consider the following function: int secret(int m, int n) { int temp = n; for (int i = 1; i <…
A: Explanation: i) cout << secret(5, 4) << endl; The operations involved in the above…
Q: 5. Consider the following c code: int k; int l; int *p; int *s; k=20; 1=30; p=&l; s=&k; *p= 5; What…
A: int k; int l; Above 2 lines defines 2 variable => k, l int *p; int *s; Above 2 lines…
Q: Here's the task in c program that I need. Instructions: Ask the user for a string input From…
A: Algorithm: Start Read a string s Iterate through the string from i=0 to s[i]!='\0' If…
Q: Given the following function definitions, write matching precondition and postcondition comments.…
A: In C++ programming languge, the comments are written by using the // or /* */. The symbol // is used…
Q: Consider the following code segment. It is designed to convert letter grades to grade points.…
A: There is Nothing Wrong with this code segment. Option 2,3 ,4 are False.
Q: Write a program with the use of if else statement and switch cases that prompts the user to assign…
A: Introduction: Here we are required to create a menu driven program that asks a use to enter 3…
Q: Find the contents of AL, BL and CL after execution of the following program MOV AL, 42h MOV CL, AL…
A: Given program MOV AL,42h ;AL=42h MOV CL,AL ; CL=42h DEC AL ;AL=41h MOV BL,AL…
Q: ease note this is not Java or C++ Complete the program 'Bcast-Reduce-Assignment.c' to make the…
A: #include <stdio.h>#include <stdlib.h>#include <mpi.h> int main(void){int my_rank,…
Q: The problem statement is described in the problem_statement.pdf file. Write the solution into the…
A: Below i have answered:
Q: Modify the below program that the input values representing fractions are stored with denominators…
A: [Java Code ] //Import the essential package import java.util.ArrayList; import…
Q: The program below stores 80 bool values into a char arr[10]. Complete setBool and getBool. In both…
A: Actually, array is a collection of elements.
Q: Given the following allocation graph, which of the following statements is correct? R1 R3 P1 P2 P3…
A: here have to determine about find dead lock and cycle in diagram.
Q: Write a program in C that does the following. The program starts by offering the user the following…
A: The program where a user inputs a value to perform an operation from a menu of choice is called…
Q: Your program should be modular and consists of the following functions: a) read () : - Ask the user…
A: def write_to_file(table):file = open("output.txt", "w")headerLine1 =…
Q: Code language Java 1, Add a print statement to say “Multiplication Table” and then prompt the user…
A: Lets see the solution in the next steps
Q: Refer to Code Segment 1 and Code Segment 2. Assume variables have been declared accordingly with…
A: Question 1. Answer: True. Explanation: Because we use 2 loops which are and every value I it will…
Q: Write a program given the following requirements Loop through numbers 1 through 50. If a number is…
A: Here I have created the for loop to generate numbers from 1 to 50. Inside the loop, I have used…
Q: 0; for (int x = 0; x < 7
A: ary: .long 12 .long 40 .long -2 .long 89 .long 35…
Q: Write the magic number program in C++ so that the user can guess at more than one magic number where…
A: Step 1: Declare variables Step 2: Generate random number Step 3: Give Four chance to user Step 4:…
Q: Read an integer value into variable num1 and another integer value into variable num2 and to do the…
A: Here, first you need to declare 2 integer variables num1 and num2 and other variable for product of…
Q: the following program MOV AL, 42h MOV CL, AL AL MOV BL, AL NOT BL ADD AL, BL LABEL: AND BL, AL NEG…
A: MOV AL, 42h moving 42h in AL register MOV CL, AL save current mode MOV BL, AL Copy…
Q: generator function that generates each of the numbers requested in the previous question (that are…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: Read an integer value into variable num1 and another integer value into variable num2 and to do the…
A: A required program is as follows, #include<iostream> using namespace std; int main() { int…
Q: My question: I don't understand why the last output has two letters inside. Can you please fix my…
A: Let's understand this one by one . You have to find the most repeated char from the string and…
Q: Consider the following C++ function. int mystery(int num1, int num2){if (num1 > 0){for (int i =…
A: C++ Program: #include<iostream> using namespace std; int mystery(int num1, int num2) { if(num1…
Q: In C++ Explain why the error is coming to this code? #include int f(int &x, int c) {
A: C++ is a cross-stage language that can be utilized to make elite applications. It gives software…
Q: Write a C program that has two functions- main and sort • The sort function accepts three integers…
A: Code: #include <stdio.h>//function prototype for sortvoid sort(int, int, int);//main…
Q: The topic is Booth's algorithm - Explain this C programming code - i have a seminar. //header files…
A: Booth's Multiplication Algorithm: Booth’s algorithm is a multiplication set of rules that multiplies…
Q: Q2: Write a whole C++ program that shows the following results by using construct and deconstruct…
A:
Use a trace table to show what is the output of the following
#include <isotream>
main()
{
int i, j = 9;
for ( i=2; (i<=17) && (j>1); i=i*2)
{
j = j-3;
cout << i << " " << j << endl;
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Please note this is not Java or C++ Complete the program 'Bcast-Reduce-Assignment.c' to make the program have the output as follows if we run the program using 2 processes. The input sequence is: 0 1 2 3 The output sequence is: 0 2 6 12 This is an MPI program and the code below is partially finished. i am supposed to have input above result in the output above. ////////////////////////////////////////////////////////////////////////////// This is a simple MPI program using MPI_Bcast and MPI_Reduce functions//// Compile: mpicc Bcast-Reduce-Example.c -o Bcast-Reduce-Example// // Run: mpiexec -n <p> ./Bcast-Reduce-Example//// -p: the number of processes/////////////////////////////////////////////////////////////////////////// #include <stdio.h>#include <stdlib.h>#include <mpi.h> int main(void){int my_rank, comm_sz;int i; int Count = 4;int Number[4]; int PartialResult = 0;int Result;…. Trace the following code by showing the values of the 3 variables in the table on the right, for each line of code that is executed (after the line is executed): //Start of execution x y z $x= 1; ----------------> $y = 2; ----------------> $z = 3; ----------------> $x = ($y+$z)/2; ----------------> $y = 8; ----------------> $z = ($x+$y)/2; ----------------> $y/=2; ----------------> $z*=$y; ---------------->The Java code must have the structure as shown in the picture and pay attention to which outputs should be shown for some example inputs: Develop with Java programming language a calculator (console application) that takes a number, a basic math operator ( + , - , * , / , % ), and a second number all from user input, and have it print the result of the mathematical operation. The mathematical operations should be wrapped inside of functions. Note: Do please use the provided source code template to implement your solution. The purpose of this problem is not only to assess the students' ability to build a valid implementation but also to assess the ability to read the Java code. Input: On single line a number, a basic math operator ( + , - , * , / , % ), and a second number all from user input. Output: On new line result of the mathematical operation. In the case of "Division by zero" you must printout the text message "Error". Example 1: 4 + 812 Example 2: 4 * 832 Example 3: 4 % 20…
- The problem is from Introduction to Programming and Data Structures with C++, 4th edition Write a program that prompts the user to enter the number of students and each student’s name and score, and displays the name and score of the student with the highest score and the student with the second-highest score.Sample RunEnter the number of students: 5Enter a student name: SmithEnter a student score: 60Enter a student name: JonesEnter a student score: 96Enter a student name: PetersonEnter a student score: 85Enter a student name: GreenlawEnter a student score: 98Enter a student name: ZhangEnter a student score: 95Top two students:Greenlaw's score is 98.0Jones's score is 96.0Hello, I am struggling with getting this DICE GAME to function properly. I have made an attempt to try and get the overall program to debug and run without errors, but to no avail. If I can get some help getting my PYTHON program to Run Correctly. #Lab 7-3 The Dice Game #add libraries needed playerTwo = 'NO NAME' playerOne = 'NO NAME' inputNames = ("enter name") import random #the main function def main(): print #initialize variables endProgram = "no" playerOne = "NO NAME" playerTwo = "NO NAME" #call to inputNames playerOne, playerTwo = inputNames(playerOne, playerTwo) #while loop to run program again while "endProgram" == 'no': #initialize variables p1number = 0 p2number = 0 winnerName = 'NO NAME' #call to rollDice winnerName = "rollDice"(p1number, p2number, playerOne, playerTwo, winnerName) #call to displayInfo displayInfo: ("winnerName") #end of while loop endProgram = "raw_input"('Do you want to end program?(Enter yes…Please help me with the below please post the program below into the bigger program. And please ensure that the big program works class Main { static int fT = 2, ST = 2, CT = 0; static int fN=3,sN=3,cN=0; static void number(int num) { if (num < 17) { return; } else { System.out.print(num + " "); // call function recursively number(num - 1); } } static void number1(int num) { if (num < 9) { return; } else { System.out.print(num + " "); // call function recursively number1(num - 2); } } static void number3(int num) { if (num > 18) { return; } else { System.out.print(num + " "); // call function recursively number3(num + 2); } } static void number4(int num) { if (num > 10) { return; } else { System.out.print(num + " "); // call function recursively number4(num + 1); } } static void number5(int…
- A java program where the system should use the following methods: .a) Lagrange interpolation for finding missing values of a function .b) A function implementing multiple application of the trapezoidal rule .c) A function implementing the composite Simpson's rule SHOULD ALLOW THE USER TO : Enter the known values of a function to be integrated or load them from a text file Enter a value of the parameter h and n (the number of intervals) .c) Choose a method to be usedI would like some help in java note: this question needs to be solved using only WHILE loopIn the following code stream, identify if there are any hazards. Crisply describe if it is possible to get around the hazards, and what the resulting steps will be. lw r2, 0(r1) add r3, r2, r3 sub r1, r1, r4
- In C++, write a program that inputs three integers from the keyboard and prints the sum, average, product, smallest and largest of these numbers. The screen dialog should appear as follows: Input three different integers: 13 27 14 Sum is 54 Average is 18 Product is 4914 Smallest is 13 Largest is 27What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. NO language of "break" or "true" please! PLEASE USE THE OUTLINE GIVEN BELOW TO WRITE THE CODE: # What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)?# I have given you the skeleton and some of the code... you complete it using a frequency table!# Note: In a classroom of only 23 people, the probability is about 50.7% !# Try first with 10000 trials and then try with 100000 trials. This code runs somewhat slowly in repl.it import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1…Write a java program that asks a user to enter a set of positive integer values. When the user stops(think of sentinel value to stop), the program displays the maximum value entered by the user. Yourprogram should recognize if no value is entered without using counter. Sample run: