#include <stdio.h>
int main() {
// contare da 1 a 10
int i;
for ( i=1 ; i <= 10 ; i = i + 1 ) { // i = i + 1 oppure i+=1 opppure i++
printf("%d\n",i);
}
printf("------------------\n");
// contare da 10 a 1
for ( i=10 ; i >= 1 ; i = i - 1 ) { // i -= 1 oppure i--
printf("%d\n",i);
}
printf("------------------\n");
// stampare solo i numeri pari da 1 a 10
for ( i=1 ; i <= 10 ; i = i + 1 ) { // i = i + 1 oppure i+=1 opppure i++
if( (i % 2) == 0 ) {
printf("%d\n",i);
}
}
printf("------------------\n");
// stampare solo i numeri multipli di 3 da 1 a 100
for ( i=1 ; i <= 100 for ( i=1 ; i <= 10 ; i = i + 1 ) { // i = i + 1 oppure i+=1 opppure i++
if( (i % 2) == 0 ) {
printf("%d\n",i);
}
} ; i = i + 1 ) { // i = i + 1 oppure i+=1 opppure i++
if( (i % 3) == 0 ) {
printf("%d\n",i);
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: