Loops - Reading Assignment


#222
  • What is looping control flow allowing us to do?
    Looping control ow allows us to go back to some point in the program where we were before and repeat it with our current program state
  • Describe what “loops” do in your own words.
    Is a way of a pattern so you don’t need to receptively write the same code again
  • What is the difference between while and do-loops?
    A do loop always executes its body at least once, and it starts testing whether it should stop only after that first execution.
  • What is indentation?
    Spaces used to make the structure of the code stand out

#223
What is looping control flow allowing us to do?
  • allows us to repeat statements and command blocks until a desired state has been reached - thereby saving repetition of coding. In terms of flow control, the flow of the program loops over the same code until the desired state has been reached.
    Describe what “loops” do in your own words.
  • run a sequence of commands multiple times
    What is the difference between while and do-loops?
  • while loops will run a section of code until the ‘while expression’ returns false. a Do-While loop will do the same thing, except it will always run the code at least once before testing the ‘while expression’.
    What is indentation?
  • just the way code appears on the page. Makes it easier to read by indenting code blocks a the same level of indentation. most important thing is to stick to the same indentation rules throughout your program.

#224
  • What is looping control flow allowing us to do?
    Looping control flow allows us to go back to some point in the program where
    we were before and repeat it with our current program state.
  • Describe what “loops” do in your own words.
    Loop is the way to make the software do and repeat an step multiple times
  • What is the difference between while and do-loops?
    a do loop always executes its body at least once, and it starts testing
    whether it should stop only after that first execution
  • What is indentation?
    make the structure of the code stand out. With
    proper indentation, the visual shape of a program corresponds to the shape of
    the blocks inside it.

#225

Looping control flow allows us to go back to a previous place in the code and repeat it.
2)
This allows the programmer to perform a certain task unitl values are met thus executing a new branch of the program.
3)
A while loop will run indefinitely until the condition is false. The do part always runs once whether the condition is true or false. It saves time.
4)
Indentation is the increase or decrease of space between the left and right margin (space) of a paragraph or line or statements so that code hierarchy make sense and code becomes more readable.


#226
  1. it allows us to execute a function when a certain condition is true. It also allows us to automatically change/update values according to condition.
  2. Same as response to 1.

3.A do loopisacontrolstructuresimilartoa while loop. Itdiffersonlyonone point: a do loop always executes its body at least once, and it starts testing whether it should stop only after that first execution.
4. Indentation are spaces and line breaks between different parts(blocks) of code. Indentation inside blocks is to make the structure of the code stand out. In code where new blocks are opened inside other blocks, it can become hard to see where one block ends and another begins. With proper indentation, the visual shape of a program corresponds to the shape of the blocks inside it.


#227

1: Loop control flow allows us to go back within the program at some point and repeat with it’s current state.

2: A loop provides the ability to circulate instructions until it successfully unifies a result.

3: A do loop will result it’s body at least once and will start testing after it’s first execution.

4: indentation makes the code stand out and organises it. Visually it corresponds to the shape of the blocks inside it.


#228
  1. What is looping control flow allowing us to do? provides a way to run a piece of code multiple times

  2. Describe what “loops” do in your own words. allows us to go back to a point in the program and repeat

  3. What is the difference between while and do-loops? while may not execute its body, do loop always executes its body at least once

  4. What is indentation? spaces before the start of a line (makes your code more readable)


#229
  1. What is looping control flow allowing us to do?
    Looping control flow allows us to go back to some point in the program where we were before and repeat it with our current program state.

  2. Describe what “loops” do in your own words.
    An efficient way of performing code multiple times without typing again and again. And it will stop if there’s set requirement to do so.

  3. What is the difference between while and do-loops?
    The program continues running once while is executed.
    Do -loops // always executes its body at least once, it will ask again and again until it gets something that is not an empty string.

  4. What is indentation?
    To write your code with clear way and make it more readable and easy reference in future. It can be a space or double space or a tab to align your code.

:tada: :tada: :tada: :tada: :tada: :tada: :tada: :tada: :tada:


#230

First ex. C++. Have a fun!

#include <iostream>

using namespace std;

void stupidGame(int colAttempts = 5){
    int randomNumber = 0;
    int numberIs;
    int counter = 1;

    cout << "Player 1 - set random number: " << endl;
    cin >> randomNumber;

    while(counter < colAttempts){
        cout << "Attempt is: " << counter << endl;
        cout << "Player 2 - what number set Player 1?";
        cin >> numberIs;
        if(randomNumber < numberIs){
            cout << "No, too hide!" << endl;
        }
        else if(randomNumber > numberIs){
            cout << "No, too low!" << endl;
        }
        else if(randomNumber == numberIs){
            cout << "Yes, number is: " << randomNumber << endl << "Life is good, dude!" << endl;
            break;
        }
        if(colAttempts == counter + 1){
            cout << "colAttempts is null. Player 2 is loss. Sorry" << endl;
            break;
        }
        counter++;
    }
}

int main()
{
    stupidGame(5);
    return 0;
}

#231
  • What is looping control flow allowing us to do?
    Control flows allow us to repeat a part of the program that was used before and to continuously run a piece of code.
  • Describe what “loops” do in your own words.
    A line of code that begins with the word “while” and runs the execution until the variable to stop output is met.
  • What is the difference between while and do-loops?
    A while loop, has a conditional statement that provides continuous as long as the value is true.
    A do loop, always executes the first and after that first execution it checks to see if it should continue.
  • What is indentation?
    spaces added to lines of code to make it easily readable.

#232
  1. It just let us go back to earlier point of the program with the values of the current state and repeat the operation.
  2. Loop is piece of code that executes an operation repeatedly until the condition is met.
  3. White loop executes if and only if the condition is satisfied, however Do-While loop executes once even before the condition is presented, so you will get an output even if the condition is not met.
  4. Indentation is used to keep the program orderly and easy to read manner.

#233
  1. Looping control allows us to go back in the program and repeat it with our current state.
  2. Loops call up a variable, give the variable a range for the loop to perform operations, and can increment the variables for each repetition.
  3. While loops will perform an operation for as long as a value stays true. Do loops always execute at least once.
  4. Indentation gives the program a visual framework for coders but is not necessary to run JavaScript.

#234
  1. Looping allows us to repeat blocks of code with the current program state.

  2. Loops return execution of the program to the beginning of a code block so that it can execute again on updated data.

  3. A while loop only executes its code block if its Boolean condition evaluates to true, whereas a do loop always executes its code block at least once.

  4. Indentation increases code readability by giving visual cues to the structure of the code.


#235
  1. It allows us to save a lot of work and to carry out a lot of commands in one expression
  2. They execute some code multiple times, usually with changing conditions, and they are doing so until a condition of this loop is not valid anymore
  3. In while loops we first check the condition, and only afeter that start with executing the code, in do-while construction, we first make one iteration, and only after that we check the condition - after that, it behaves the same like while loop
  4. It is a graphical way of writing code, in a user-friendly way, to account for specific blocks in code and make it graphically distinguishable

#236
  1. It’s allowing the programme to go back to the initial start/point from where the programme can repeat a condition until it is false.
  2. Allow us to repeat a previous action, in other words going back to the start of the programme.
  3. While - will run forever until a condition is false; Do - will run at least one, and then check the condition if it is already false.
  4. Provides clarity to the code.

#237
  • Looping control flow instructs the program to go back several lines of code above and execute it again.
  • Loops simplifies repetitive tasks by instructing the program to run code for as long as a condition is true. It also follows one of the rule of developers: do not write 2 times the same code.
  • DO loops allows a code to be executed at least once and repeat if necessary.
  • Indentation is a human readable way of presenting the code using returns, spaces and tabs.

#238

What is looping control flow allowing us to do? : Automate and calculate responses
Describe what “loops” do in your own words. : repeat an action until a condition is met
What is the difference between while and do-loops? : DO loops execute at least once
What is indentation? : a formatting exercise to make loop and other self contained statements easier to read


#239

What is looping control flow allowing us to do?

  • Looping control allows us to go back in the code and repeat a task in an automated way
    Describe what “loops” do in your own words.
  • Loops are useful to reuse lines of code multiple times until a given condition is met
    What is the difference between while and do-loops?
  • do-loops always run at least once
    What is indentation?
  • Indentation is too add spaces before new lines of code. It is a good practice to keep the code organized and easily identify blocks

#240
  1. Allows us to go to a point where we created a condition in the program and repeat it.

  2. loops allow you to do some operation repeatedly.

  3. in while loops, test expression is checked at first but, in do…while loop code is executed at first then the condition is checked.

  4. Using tabs/spaces to improve your program’s readability.


#241

1.It allows us to repeat lines of code without typing it out.
2.Loops repeated cycles of instructions until it has completed.
3. A do while list runs at least 1 time where as a while list wont.
4. This is the spacing out of code to make it readable.