From f5281689c95758f17628f0286e0265ecf3385a8e Mon Sep 17 00:00:00 2001 From: Miguel Date: Fri, 21 Sep 2018 11:44:55 +0200 Subject: little div prog and cleaning userspace --- userspace/div.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 userspace/div.c (limited to 'userspace/div.c') 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 +#include + +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; +} -- cgit v1.2.3