-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintal_demo.c
executable file
·66 lines (52 loc) · 1.15 KB
/
intal_demo.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//Demo program for the "intal" library of integers of arbitrary length.
//intal stands for "int"eger of "a"rbitrary "l"ength.
#include <stdio.h>
#include <stdlib.h>
#include "intal.h"
int main() {
intal* i1 = create_intal();
intal* i2 = create_intal();
intal *i5 = NULL;
char *s = (char *)malloc(sizeof(char) * 1000000);
scanf("%s", s);
read_intal(i1, s);
scanf("%s", s);
read_intal(i2, s);
free(s);
check_zero_intal(&i1); //removing preceding 0s from numbers.
check_zero_intal(&i2);
printf("i1 = ");
print_intal(i1);
printf("\n");
printf("i2 = ");
print_intal(i2);
printf("\n");
printf("Add : ");
i5 = add_intal(i1, i2);
print_intal(i5);
printf("\n");
delete_intal(&i5);
printf("Subtract : ");
i5 = subtract_intal(i1, i2);
print_intal(i5);
printf("\n");
delete_intal(&i5);
printf("Multiply : ");
i5 = multiply_intal(i1, i2);
print_intal(i5);
printf("\n");
delete_intal(&i5);
printf("Divide : ");
i5 = divide_intal(i1, i2);
print_intal(i5);
printf("\n");
delete_intal(&i5);
printf("Power : ");
i5 = pow_intal(i1, i2);
print_intal(i5);
printf("\n");
delete_intal(&i1);
delete_intal(&i2);
delete_intal(&i5);
return 0;
}