diff options
| author | Miguel <m.i@gmx.at> | 2018-09-21 11:44:55 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-09-21 11:44:55 +0200 |
| commit | f5281689c95758f17628f0286e0265ecf3385a8e (patch) | |
| tree | 312b16fcbaf40b7e32c1b7e3fe783477e8d9674c /userspace/div.c | |
| parent | e68c8e3468076afa171ffff82b9bafa4cbc335bb (diff) | |
little div prog and cleaning userspace
Diffstat (limited to 'userspace/div.c')
| -rw-r--r-- | userspace/div.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/userspace/div.c b/userspace/div.c new file mode 100644 index 0000000..595084e --- /dev/null +++ b/userspace/div.c @@ -0,0 +1,23 @@ +// divide one param by another // +// can be easily be used to provoke division by zero excpetion // + +#include <stdio.h> +#include <stdlib.h> + +int main(int argc, char **argv) +{ + if (argc!=3) + { + printf("Divide two integers and print result \n"); + printf("usage : %s [quotient] [divisor]\n",argv[0]); + return EXIT_FAILURE; + } + + int q=atoi(argv[1]); + int d=atoi(argv[2]); + printf("Divide %i by %i\n",q,d); + printf("%i / %i = %i\n",q,d,q/d); + printf("%i mod %i = %i\n",q,d,q%d); + + return EXIT_SUCCESS; +} |
