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 [2013/08/05 15:37] – zufd | 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 57: | Line 57: | ||
</ | </ | ||
* Run it with " | * Run it with " | ||
- | * Nothing should happen, it's normal because you didn' | + | * Nothing should happen, it's normal because you didn' |
* now recompile your program with the following line | * now recompile your program with the following line | ||
< | < | ||
Line 64: | Line 64: | ||
* Run it again | * Run it again | ||
* Hello world ! | * Hello world ! | ||
+ | ===== Exercice 3 : scanf ===== | ||
+ | |||
+ | * Open a terminal | ||
+ | * Create your file by writing the following command | ||
+ | <code c> | ||
+ | vim ex3.c | ||
+ | </ | ||
+ | * Enter insertion mode by pressing Insert | ||
+ | * Write the lines below | ||
+ | <code c> | ||
+ | # | ||
+ | |||
+ | int main(int argc, char** argv) | ||
+ | { | ||
+ | char nom[14]; | ||
+ | printf(" | ||
+ | scanf(" | ||
+ | printf(" | ||
+ | | ||
+ | return 0; | ||
+ | } | ||
+ | </ | ||
+ | * Then press Esc key | ||
+ | * Write :wq | ||
+ | * Compile your code with the following line | ||
+ | < | ||
+ | gcc -Wall ex3.c -o ex3 | ||
+ | </ | ||
+ | * 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.1375717033.txt.gz · Last modified: 2013/08/05 15:37 by zufd