c/imports,comments,output,for
This commit is contained in:
parent
920e032038
commit
d70d2a03d7
1 changed files with 30 additions and 5 deletions
|
@ -1,15 +1,27 @@
|
|||
C
|
||||
=
|
||||
|
||||
Imports
|
||||
-------
|
||||
|
||||
.. code:: c
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
Comments
|
||||
--------
|
||||
|
||||
.. code:: c
|
||||
|
||||
// single line comment
|
||||
/* multi line comment */
|
||||
|
||||
Main
|
||||
----
|
||||
|
||||
.. code:: c
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue