programming:c:hello_world
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| programming:c:hello_world [2014/12/11 16:01] – czuber | programming:c:hello_world [2014/12/11 16:22] (current) – czuber | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Hello world ! ====== | ====== Hello world ! ====== | ||
| - | ===== Exercice 1 ===== | + | ===== Exercice 1 : printf |
| * Open a terminal | * Open a terminal | ||
| Line 64: | Line 64: | ||
| * Run it again | * Run it again | ||
| * Hello world ! | * Hello world ! | ||
| - | ===== Exercice 3 ===== | + | ===== Exercice 3 : scanf ===== |
| * Open a terminal | * Open a terminal | ||
| Line 93: | Line 93: | ||
| </ | </ | ||
| * Then run your programm by typing " | * Then run your programm by typing " | ||
| + | ===== Exercice 4 : for ===== | ||
| + | |||
| + | * Open a terminal | ||
| + | * Create your file by writing the following command | ||
| + | <code c> | ||
| + | vim ex4.c | ||
| + | </ | ||
| + | * Enter insertion mode by pressing Insert | ||
| + | * Write the lines below | ||
| + | <code c> | ||
| + | # | ||
| + | |||
| + | int main(int argc, char** argv) | ||
| + | { | ||
| + | int nbrMax; | ||
| + | int i = 1; | ||
| + | printf(" | ||
| + | scanf(" | ||
| + | printf(" | ||
| + | for(i=1; | ||
| + | { | ||
| + | printf(" | ||
| + | } | ||
| + | | ||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
| + | * Then press Esc key | ||
| + | * Write :wq | ||
| + | * Compile your code with the following line | ||
| + | < | ||
| + | gcc -Wall ex4.c -o ex4 | ||
| + | </ | ||
| + | * Then run your programm by typing " | ||
| + | ===== Exercice 5 : for in for ===== | ||
| + | |||
| + | * Open a terminal | ||
| + | * Create your file by writing the following command | ||
| + | <code c> | ||
| + | vim ex5.c | ||
| + | </ | ||
| + | * Enter insertion mode by pressing Insert | ||
| + | * Write the lines below | ||
| + | <code c> | ||
| + | # | ||
| + | |||
| + | int main(int argc, char** argv) | ||
| + | { | ||
| + | int i = 1; | ||
| + | int j = 1; | ||
| + | int nbrMax = 10; | ||
| + | for(i=1; | ||
| + | { | ||
| + | for(j=1; | ||
| + | { | ||
| + | printf(" | ||
| + | } | ||
| + | printf(" | ||
| + | } | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | </ | ||
| + | * Then press Esc key | ||
| + | * Write :wq | ||
| + | * Compile your code with the following line | ||
| + | < | ||
| + | gcc -Wall ex5.c -o ex5 | ||
| + | </ | ||
| + | * Then run your programm by typing " | ||
programming/c/hello_world.1418313705.txt.gz · Last modified: 2014/12/11 16:01 by czuber