c/char,conditions

This commit is contained in:
Marc Beninca 2018-12-11 21:53:43 +01:00
parent ddd1735553
commit 4b3b97e04b

View file

@ -19,7 +19,29 @@ Input
.. code:: c .. code:: c
int entry1 = 0; int entry1 = 0;
char operator;
int entry2 = 0; int entry2 = 0;
printf("type in 2 integers\n"); printf("type in 2 integers\n");
scanf("%d%d", &entry1, &entry2); scanf("%d%s%d", &entry1, &operator, &entry2);
printf("sum: %d\n", entry1 + entry2); printf("sum: %d\n", entry1 + entry2);
Conditions
----------
.. code:: c
if (condition) {
expression1;
} else {
expression2;
}
.. code:: c
switch (operator) {
case '+':
expression1;
break;
default:
printf("Nope!\n");
}