summaryrefslogtreecommitdiffstats
path: root/4/3.c
diff options
context:
space:
mode:
authorSadeep Madurange <smadurange@users.noreply.github.com>2021-12-07 18:29:20 +0800
committerSadeep Madurange <smadurange@users.noreply.github.com>2021-12-07 18:29:20 +0800
commitbd9550e2e7f2484ccbd6f9c6d1d2a520dbddc82c (patch)
treee45fa1999205d6b723a47ae2988130a06b5bc77d /4/3.c
parent6e31f2496eda9d71152acaf5b8db576af0b141a8 (diff)
downloadk&r-exercises-bd9550e2e7f2484ccbd6f9c6d1d2a520dbddc82c.tar.gz
4.3
Diffstat (limited to '4/3.c')
-rw-r--r--4/3.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/4/3.c b/4/3.c
index e2f2e7c..d5810a9 100644
--- a/4/3.c
+++ b/4/3.c
@@ -48,6 +48,13 @@ int main(int argc, char *argv[]) {
else
printf("error: division by zero\n");
break;
+ case '%':
+ op2 = pop();
+ if (op2 != 0.0)
+ push((int)pop() % (int)op2);
+ else
+ printf("error: division by zero\n");
+ break;
case '\n':
printf("\t%.8g\n", pop());
break;