Wednesday, October 10, 2018

Algorithm Program Control Repetition


Program Control Repetition
Hello everyone so today i will tell you about my sumarry for algorithm class at 10 oktober 2018.. this blog should be uploaded today but there was a problem with my internet connection.
LETS BEGIN,

What is Repetition?
- One more instruction  that can be repeated in any time.
- Number of repetition can be predefined (hard-coded in program) or defined later at run time.

What operation that used in Repetition?
1.      For
2.      While
3.      Do While
Ok that was 3 major discussion for us and i will explain about the first one because untill the end of the class, My lecture only tell about the “ For “ and that’s make me confident to create this blog so lets go.

For
Here’s the formula of “For”
For(Exp1,Exp2,Exp3){
{
            Statement1
            Statement2
}
Well now lets break down the formula
So first Exp means Expression
Exp 1   :   initialization
Exp 2    :   conditional
Exp 3   :   increment or decrement
exp1, exp2 and exp3 are optional
then there is statment1 and statement2 which is a statement like printf and something like that
so now lets take a look to an example:
#include<stdio.h>
Int main()
{
            Int x;
            For(x=1; x<=10; x++){
                        Printf(“%d”\n);
}
Return(0);
)
Lets break down this example again
So,
X=1 is the exp1 thats mean the initialization process.
X<=10 is the exp2 thats mean the conditional after the process done.
X++ is the Increment or decrement or we can say the after condition of the statement.

INFINITE LOOP
Loop with no stop condition can use “for-loop” by removing all parameters (exp1, exp2, exp3). To end the loop use break.

NESTED LOOP
Loop in a loop. The repetition operation will start from the inner side loop.

So thats all for today thx guys for read my blogs

Nim:2201736385
Binus.ac.id
Skyconnectiva.
Albert TG

No comments:

Post a Comment