-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple.c
More file actions
47 lines (40 loc) · 743 Bytes
/
simple.c
File metadata and controls
47 lines (40 loc) · 743 Bytes
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
/* This is free and unencumbered software released into the public domain.
* Refer to LICENSE.txt in this directory. */
/* Simple arithmetic program with subroutines. */
#include <stdio.h>
#include <stdlib.h>
int a = 0, b = 1, c = 2;
static int
add(int x)
{
a += x;
b += x;
c += x;
printf("After +%d a=%d, b=%d, c=%d\n", x, a, b, c);
return a + b + c;
}
static int
multiply(int x)
{
a *= x;
b *= x;
c *= x;
printf("After x%d a=%d, b=%d, c=%d\n", x, a, b, c);
return a + b + c;
}
int
main(void)
{
int x, y, z;
a++;
b++;
c++;
x = add(2);
a++;
b++;
c++;
y = multiply(3);
z = y * y;
printf("x, y, z now %d, %d, %d\n", x, y, z);
return EXIT_SUCCESS;
}