Question

In: Computer Science

2. What loops run while in a true condition?

 
In your own words write an example of a loop that you perform in your day to day life
 
Sample answer - If(“want to make money” –eq “true”){
 
Goto-work
 
Now answer the following questions
 
2. What loops run while in a true condition?
 
3. What loop runs while in a false condition?
 
4. What PowerShell loop sets the variable, the condition, and the iteration of the variable all in one?
 
5. Describe in your own words what each loop is used for.

Solutions

Expert Solution

 

2.

“While” loop

Explanation

The while loop will execute while in a true condition.

3.

“Do until”

Explanation

The “do until” loop will execute while in a false condition.

4.

The ‘for’ loop is the loop that sets the variable, the condition, and the iteration all in one statement.

5.

The ‘foreach’ loop is one that is especially powerful the reason is that it iterates through a collection of objects. You can then work with each object in the collection individually.

 


Related Solutions

how would i change the for loops to while loops in the code below #include<stdio.h> #include<stdlib.h>...
how would i change the for loops to while loops in the code below #include<stdio.h> #include<stdlib.h> int main() { int seed; // Taking seed value as input from the user printf("Enter a seed value (0 to quit): \n"); scanf("%d", &seed); // Running the loop until user enters 0 to quit // count array will count frequency of 0 , 1 , 2 ,3 int count[4]; for (int i = 0; i < 4; i++) count[i] = 0; while (seed !=...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a...
Python Exercises = Sentinel Values and While Loops #Exercise 1 #Write a while loop with a sentinel value #This while loop ends when the user enters a 1, the sentinel value #Assign the number 8 to a variable which will serve as the sentinel value #Condition: while variable is not equal to 1 #Action: display the number assigned to the variable #Use an input statement (no prompt) to ask the user for a number and assign this number to the...
Explain in word what “no arbitrage” condition mean and why this condition may not hold true...
Explain in word what “no arbitrage” condition mean and why this condition may not hold true in reality? Bring at least 2 reasons for it.
The purpose of this exercise is to give you experience in writing condition-controlled loops. Create a...
The purpose of this exercise is to give you experience in writing condition-controlled loops. Create a code in Python that will print monthly loan amortization schedule given the loan amount (P), APR i.e. Annual Percentage Rate (r=APR in %/12), loan terms in number of months (n). Please use these formulas: Monthly Payment (A) = P * ((r * (1 + r)**n)/(((1+r)**n)-1))            Monthly Interest Pmt (mIP)= r * Total Remaining Balance Monthly Principal Pmt (mPP) = A –...
This assignment will acquaint you with the use of while loops and boolean expressions. You will...
This assignment will acquaint you with the use of while loops and boolean expressions. You will create a program that acts as a score keeper of a racquet ball game between two players. The program will continually ask the user who the winner of every point is as the game is played. It will maintain the scores and declare the match is over, using these rules: (1) A game is over when a. one of the players wins 7 points...
1. The correct mean for Condition One is _______ while the correct mean for Condition Two is ______:
Condition 1 Scores Condition 2 Scores 1 8 2 3 3 4 3 10 4 2 4 8 4 7 5 7 2 8 6 9 2 10 5 10 Column Mean Column Median Column Mode Standard Deviation Column Range 1. The correct mean for Condition One is _______ while the correct mean for Condition Two is ______: A. 3.50 and 8.00 B. 3.42 and 7.17 C. 4.00 and 8.00 D. 1.51 and 2.76 E. 7.17 and 3.42 2. The...
Given the following pre-condition and program segment, what is the post-condition for y? // Pre-condition: -2...
Given the following pre-condition and program segment, what is the post-condition for y? // Pre-condition: -2 <= x < 4 y = 2*x*x - x +3
I need a C++ program using while loops that counts the number of characters in a...
I need a C++ program using while loops that counts the number of characters in a sentence. The user inputs a sentence and then terminates the input with either '.' or '!'. And then it needs to count and display the number of a's, e's, i's, o's, u's, and consonants. The program should read both lower and upper case. They don't want us using switch statements or string operators, and want us to us if else if statements. I have...
1.While the biceps is contracting, there is no activity in the triceps. True or false 2.As...
1.While the biceps is contracting, there is no activity in the triceps. True or false 2.As contractile strength increases, ____________ muscle motor units become involved in the contraction. More or ess 3.A maximum strength skeletal muscle contraction can be sustained indefinitely. True or false
using java LO: (Apply) Students will write loops that iterate until a condition is met. LO:...
using java LO: (Apply) Students will write loops that iterate until a condition is met. LO: (Analyze) Students will identify edge cases from a problem statement. In this game of volleyball, two teams compete to be the first team to score 21 points. However, to win the game, a team must also lead by two points. For example, if team A is tied with team B (20-20) and then scores, they will only be ahead by one point (21-20). Then,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT