I am writing this post for my Algorithm and Programming class. It's the summary from I learned at the class. So my Algorithm and Programming class is on every Wednesday and yesterday was my class. This week we learned about repetition on c language.
What is repetition on c language? Repetition or looping on c language is repeated instructions and the amount of it could be predefined or defined later.
Types of repetition/looping:
What is repetition on c language? Repetition or looping on c language is repeated instructions and the amount of it could be predefined or defined later.
Types of repetition/looping:
- for
- while
- do-while
#For
Syntax:
for(exp1;
exp2; exp3) statement;
or:
for(exp1;
exp2; exp3){
statement1;
statement2;
…….
}
exp1 :
initialization
exp2 :
conditional
exp3 :
increment or
decrement
exp1, exp2 and exp3 are optional
Flowchart of For statement:
#While
Syntax
:
while (exp) statements;
or:
while(exp){
statement1;
statement2;
…..
}
Flowchart of While statement:
#Do While
Syntax
:
do{
< statements >;
} while(exp);
Flowchart of Do While Statement:
There are things called break and continue on repetition. Break is used to end the loop(repetition) and end the switch operation. Continue is used to skip
all the rest of statements (subsequent to the skip statement) inside a
repetition, and continue normally to the next loop.
So there are 3 types of repetition, there are For, While, and Do While. And they are used depends on the which condition an instruction will be conducted as it could be seen at the flowcharts.
This sums up things that I learned on my class this week, hope this could be useful for you guys.
Greecelia Wongsi
2201758253
CB01-CL/LR01-LEC
skyconnectiva.com



Comments
Post a Comment