c/imports,comments,output,for

This commit is contained in:
Marc Beninca 2018-12-11 22:07:14 +01:00
parent 920e032038
commit d70d2a03d7

View file

@ -1,15 +1,27 @@
C C
= =
Imports
-------
.. code:: c
#include <stdio.h>
Comments
--------
.. code:: c
// single line comment
/* multi line comment */
Main Main
---- ----
.. code:: c .. code:: c
#include <stdio.h>
main() { main() {
printf("Hello, world!\n");
system("pause"); system("pause");
} }
@ -22,15 +34,22 @@ Declarations
int entry1 = 0; int entry1 = 0;
int entry2 = 0; int entry2 = 0;
long entry = 0; long entry = 0;
float f = (float)1;
Output
------
.. code:: c
printf("int: %d\n", entry1);
printf("float: %.2f\n", f);
Input Input
----- -----
.. code:: c .. code:: c
printf("type in 2 integers\n");
scanf("%d%s%d", &entry1, &operator, &entry2); scanf("%d%s%d", &entry1, &operator, &entry2);
printf("sum: %d\n", entry1 + entry2);
Conditions Conditions
---------- ----------
@ -56,6 +75,12 @@ Conditions
Loops Loops
----- -----
.. code:: c
for (declarations;conditions;increments) {
expression1;
}
.. code:: c .. code:: c
while (condition) { while (condition) {