Data de publicació: Feb 08, 2017 10:3:53 AM
A really simple program showing how the while loop works.
It prints numbers from a min to a max number with an increment inc.
#include <stdio.h>
int main(){
int i, min, max, inc;
min = 10;
max = 30;
inc = 5;
i = min;
while (i <= max){
printf("Number %d\n",i);
i = i + inc;
}
}
Compiling and Output
[ikastenc@ikastenc while]$ make while_00
cc while_00.c -o while_00
[ikastenc@ikastenc while]$ ./while_00
Number 10
Number 15
Number 20
Number 25
Number 30
[ikastenc@ikastenc while]$