본문 바로가기

Study Meeting/빡공단 30기

[Day 13] Repeated Statement: for and while

I learned the 'for' and 'while' repeated statement which is used to repeatedly command a particularly actions.

1. 'For' statement
This iteration operates the action code while satisfying the conditional expression from the initial condition of the variable.

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    
    int i;
    
    for (initial variable; repeated condtion, incremental conditon) {
    	Action code;
    }
    
    return 0;
}

 

2. 'While' statement
This iteration is repeated if the content of the conditional expression is true.

#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    
    int i;
    
    while (conditon) {
    	Action code;
    }
    
    return 0;
}