From d70d2a03d7046ba078405f3b5ff19bec6e9ba920 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Tue, 11 Dec 2018 22:07:14 +0100 Subject: [PATCH] c/imports,comments,output,for --- in/public/code/c/index.rst | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/in/public/code/c/index.rst b/in/public/code/c/index.rst index de4c1a7..b4d8dfc 100644 --- a/in/public/code/c/index.rst +++ b/in/public/code/c/index.rst @@ -1,15 +1,27 @@ C = +Imports +------- + +.. code:: c + + #include + +Comments +-------- + +.. code:: c + + // single line comment + /* multi line comment */ + Main ---- .. code:: c - #include - main() { - printf("Hello, world!\n"); system("pause"); } @@ -22,15 +34,22 @@ Declarations int entry1 = 0; int entry2 = 0; long entry = 0; + float f = (float)1; + +Output +------ + +.. code:: c + + printf("int: %d\n", entry1); + printf("float: %.2f\n", f); Input ----- .. code:: c - printf("type in 2 integers\n"); scanf("%d%s%d", &entry1, &operator, &entry2); - printf("sum: %d\n", entry1 + entry2); Conditions ---------- @@ -56,6 +75,12 @@ Conditions Loops ----- +.. code:: c + + for (declarations;conditions;increments) { + expression1; + } + .. code:: c while (condition) {