2018-12-11 20:38:01 +00:00
|
|
|
C
|
|
|
|
=
|
|
|
|
|
|
|
|
Main
|
|
|
|
----
|
|
|
|
|
|
|
|
.. code:: c
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
main() {
|
|
|
|
printf("Hello, world!\n");
|
|
|
|
system("pause");
|
|
|
|
}
|
2018-12-11 20:43:19 +00:00
|
|
|
|
|
|
|
Input
|
|
|
|
-----
|
|
|
|
|
|
|
|
.. code:: c
|
|
|
|
|
|
|
|
int entry1 = 0;
|
2018-12-11 20:53:43 +00:00
|
|
|
char operator;
|
2018-12-11 20:43:19 +00:00
|
|
|
int entry2 = 0;
|
|
|
|
printf("type in 2 integers\n");
|
2018-12-11 20:53:43 +00:00
|
|
|
scanf("%d%s%d", &entry1, &operator, &entry2);
|
2018-12-11 20:43:19 +00:00
|
|
|
printf("sum: %d\n", entry1 + entry2);
|
2018-12-11 20:53:43 +00:00
|
|
|
|
|
|
|
Conditions
|
|
|
|
----------
|
|
|
|
|
|
|
|
.. code:: c
|
|
|
|
|
|
|
|
if (condition) {
|
|
|
|
expression1;
|
|
|
|
} else {
|
|
|
|
expression2;
|
|
|
|
}
|
|
|
|
|
|
|
|
.. code:: c
|
|
|
|
|
|
|
|
switch (operator) {
|
|
|
|
case '+':
|
|
|
|
expression1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Nope!\n");
|
|
|
|
}
|