Control Structures and Subroutines



1.when the memory alloted will exhaust,at that that the while loop will stop.because it cannot hold more numbers due to memory deficit
2.a) the first string //the condition is true because a is more than b
b) will not compile//error because = means assignment and it is not used inside if..equal to should be ==
c) the first thing //value of c is more than d.so cndition is true
d)the first thing //the condition is true.c is smaller than d
e)the second thing //c is smaller than b
f) the first thing //b is less than c
3) error because jth loop is not mentioned or given and it is tried to increment.for program to work it should be i which must be incremented
4)if i=i+2 is used after the print statement, then message will be printed 5 times
5) 5 4 3 2 1. //because value of j will print and decrement from 5 to 0.
6)
7)
Step 1: begin Step 2:Set j to 1 Step 3: if j > n then go to step 7 Step 4: if A[i] = x then go to step 6 Step 5: Set j to j + 1 Step 6: Go back to Step 2 Step 7: Print Element x Found at index j and go to step 8 Step 8: Print element not found Step 8: End
Control Structures and Subroutines I. A while loop whose condition is not made false is called...
3. A tor loop is useful when you know in advance the number of iterations to be executed. The tor loop consists of three parts each of which is separated by a semicolon (:). The first part is initialization of the variable for iteration, the second part is a test of the iteration variable and if this test fails, the loop is finished. The third part is a counter for the iteration variable. A block can be followed after the...
e. Code a while loop that determines and prints the winnings for the Daytona 500 depending upon the position after the finish-line: 1st, 2nd, or 3rd. Assume the input variable for the Scanner class, position and prizeMoney variables are already declared. Declare noWinners variable, and initialize it to the number of winners. Declare a counter-control variable for the while loop, and initialize it. When the loop is entered, prompt: The driver crossed the finish line in which place? Insert the...
Question 21 The loop condition can be a complex condition involving several operators. True OR False Question 22 final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87; if(num3-5 >= 2*LIMIT) { System.out.println ("apple"); } else { System.out.println ("orange"); } System.out.println("grape"); What prints? A. Apple B. Orange C. Grape D. apple grape E. orange grape F. Nothing. Question 23 When we use a while loop, we always know in advance how many...
Objectives:
Use the while loop in a program
Use the do-while loop in a second program
Use the for loop in a third program
Instructions:
Part A. Code a for loop to print the Celsius temperatures for
Fahrenheit temperatures 25 to 125. C = 5/9(F – 32).Output should be
in a table format:
Fahrenheit Celsius
25 ?
. .
. . . .
. .
Turn in the source and the output from Part A.
Part B. Code a while...
I am writing python code. I submitted an assignment but the professor said it was a modularization. Can you help me see what part of the code is modularization? Pseudocode: 1. Decalre MainMethod () function: # A. Parameters: Three numbers # B. Put the three numbers in reverse # 2. Main Program # A. Initialize Varibles # B. Accepts three values from the user # C. Invoke MainMethod () function, passing the three numbers as arguments in reverse # D....
The loop below stores the values 1 to 5 in myList: for (int i = 0; i < 5; i ++) { myList [ i ] = i + 1; //store values using a loop } The loop below prints the values from first to last in myList: for (int i = 0; i < myList.length; i++) { System.out.print(myList [ i ] + " "); } Use the examples on the slides to complete the lab below. Please submit the...
Linux & C code help with creating a child process and kills itself with SIGNAL. I provided most of the code, I need some help to finish. Please provide output screen shot as well. Thank you! A Process creates a child process. Child process will print out "hello 0" "hello 1" ..... 1 line per second. After a certain number of seconds(user input), it kills itself WITH signal mechanism ONLY, don't use exit() on the child. You can use alarm()...
Having trouble with the do while/while loop and the switch
statement. I got some of the switch statement but cant get the
program to repeat itself like it should.What i have so far for my
code is below. Any help is appreciated... i am not sure what I am
doing wrong or what i am missing. I am completely lost on the while
loop and where and how to use it in this scenario.
import java.util.Scanner;
public class sampleforchegg {...
VERY URGENT*** THANK YOU IN ADVANCE: THIS IS THE CODE I HAVE GOTTEN SO FAR: PYTHON This is a code that is supposed to help someone study/ practice for jeopardy. The two functions described below are required for this assignment. You may add other functions that you think are appropriate: menu() This function, which displays all the user options to the screen, prompt the user for their choice and returns their choice. This function will verify user input and ALWAYS...
Python
Testing
a) The temperature readings are correctly handled using a while
loop and the output is correct
b) The wind speed readings are correctly handled using a while
loop and the output is correct
c) The humidity readings are correctly handled using a while
loop and the output is correct
d) Works correctly overall
The program first prompts for and reads in temperatures (all integers), until a line with no characters in received. It computes the average of all...