Tag Archives: #Mastery20

Mastery20


Mastery20

Mastery20

Use of loops with “for”:
A for loop is a repetition control structure that allows you to efficiently write a loop that needs to execute a specific number of times.

Syntax:
The syntax of a for loop in C++ is:

for ( init; condition; increment )
{
statement(s);
}
Here is the flow of control in a for loop:

The init step is executed first, and only once. This step allows you to declare and initialize any loop control variables. You are not required to put a statement here, as long as a semicolon appears.

Next, the condition is evaluated. If it is true, the body of the loop is executed. If it is false, the body of the loop does not execute and flow of control jumps to the next statement just after the for loop.

After the body of the for loop executes, the flow of control jumps back up to the increment statement. This statement allows you to update any loop control variables. This statement can be left blank, as long as a semicolon appears after the condition.

The condition is now evaluated again. If it is true, the loop executes and the process repeats itself (body of loop, then increment step, and then again condition). After the condition becomes false, the for loop terminates.

link:
http://www.tutorialspoint.com/cplusplus/cpp_for_loop.htm

#Mastery20

Here is a link to my video explaining the which is me explaining how to use the FOR loop.

Hope you enjoy it and learn from it!

https://www.youtube.com/watch?v=kY5XWdtqI5Y

#Mastery20 Use of loops with for

The for repetition structure handles all the details of counter-controlled repetition. The picture shows an example.

The general format of the for structure is

for ( initialization statement; loop continuation condition; increment )

When the for structure begins executing, the control variable i is declared and inicialized to 0. Then, the loop-continuation i <= size is checked. The inicial value of is 0, so the condition is satisfied and the body statement prints the value of i, namely 0. Then the expresion i++  increments control variable i and the loop begins again with the loop-continuation test. The control variable is now equal to 1, so the final value is not exceeded and the program performs the body statement again. This process continues until the control variable i is incremented upper than the value size given by the user- this causes the loop-continuation test to fail and repetition to terminate. The program continues by performing the first statement after the for structure.

You can check my Github repository -TC1017 to see more code: https://github.com/Auralgo/-TC1017

 

From: “C++ How to program” by Deitel.

Learn To Program 2015-04-06 19:53:00

Mastery20

Un bucle es una estructura de control que repite un bloque de instrucciones. El bucle for es un bucle que repite el bloque de instrucciones un numero predeterminado de veces. El bloque de instrucciones que repite de llama cuerpo de bucle y cada repeticion se le llama interaccion. Para entender el funcionamiento del ciclo for en Python, consulté la siguiente información:
https://docs.python.org/2/tutorial/controlflow.html
http://www.mclibre.org/consultar/python/lecciones/python_for.html

for variable in elemento recorrible (lista, cadena, range, etc.):
    cuerpo del bucle

*******
Mi video:
*******
https://www.youtube.com/watch?v=ucOIdI9DEmQ
**********************
Programa hecho en Python:
**********************
https://github.com/A01630323/Learn-To-Program/blob/master/Mastery20.py

Learn To Program 2015-04-06 19:53:00

Mastery20

Un bucle es una estructura de control que repite un bloque de instrucciones. El bucle for es un bucle que repite el bloque de instrucciones un numero predeterminado de veces. El bloque de instrucciones que repite de llama cuerpo de bucle y cada repeticion se le llama interaccion. Para entender el funcionamiento del ciclo for en Python, consulté la siguiente información:
https://docs.python.org/2/tutorial/controlflow.html
http://www.mclibre.org/consultar/python/lecciones/python_for.html

for variable in elemento recorrible (lista, cadena, range, etc.):
    cuerpo del bucle

*******
Mi video:
*******
https://www.youtube.com/watch?v=ucOIdI9DEmQ
**********************
Programa hecho en Python:
**********************
https://github.com/A01630323/Learn-To-Program/blob/master/Mastery20.py

Mastery 20 – Use of loops with “for”

El ciclo For consiste en utilizar mayormente “rangos” en los cuales se define el numero de iteraciones que se pueden hacer en este ciclo.

Sintaxís:

for (inicio; mientras; incremento/decremento){

CODIGO A EJECUTAR

}

 

Más informacion: http://codigoprogramacion.com/cursos/tutoriales-c/ciclo-for-en-c-y-ejemplos.html#.VSMi8P6UeM4

 

 

#Mastery20 – For Loops

#Mastery20

Use of loops with “for”

Primero debemos llamar a nuestra librería iostream y usar using namespace std;

Segundo, debemos declarar nuestra función principal int main

Después, declaramos nuestras variables dentro del int main con tipo, nombre y variable.

Pedimos al usuario por un valor a estas variables con un cout

Guardamos este valor en una variable con un cin

Aquí utilizaremos un ciclo for para saber la tabla de multiplicar de un numero hasta el 10

Un ciclo for lleva un contador, entre parentesis del ciclo for se debe de definir y declarar un contador, y el valor que tendra en cuanto se corra el programa, la condición del ciclo, cuando se cumpla esta condición se sale del ciclo y continua con el int main , y por ultimo dentro del parentesis se debe declarar como irá incrementando el contador con i++ o i–.

Dentro de este ciclo for imprimiremos la tabla de multiplicar hasta el 10 (contador i<=10) del número que el usuario introduzca.

Terminamos fuera del ciclo for con un return 0; y guardamos compilamos, verificamos que no haya errores y corremos el programa para ver que funcione correctamente.

Aquí un ejemplo de el uso de un ciclo for:

siclo for # MAstery20

#Mastery20
here is my mastery https://youtu.be/U2zC793J3sE

siclo for # MAstery20

#Mastery20
here is my mastery https://youtu.be/U2zC793J3sE