blob: 595084e738bf365207a56bc20a548d1a55d7a354 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}
|