-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathex1_sub.c
110 lines (83 loc) · 2.71 KB
/
ex1_sub.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include <stdlib.h>
#include <stdio.h>
float double_add_func ( double *r1, double *r2 );
void double_add_sub ( double *r1, double *r2, double *r3 );
int int_add_func ( int *i1, int *i2 );
void int_add_sub ( int *i1, int *i2, int *i3 );
float real_add_func ( float *r1, float *r2 );
void real_add_sub ( float *r1, float *r2, float *r3 );
/********************************************************************/
void int_add_sub ( int *i1, int *i2, int *i3 )
/********************************************************************/
/*
Purpose:
INT_ADD_SUB adds two integers, returning the result as an argument.
*/
{
printf ( "\n" );
printf ( "INT_ADD_SUB:\n" );
printf ( " Input I1 = %d.\n", *i1 );
printf ( " Input I2 = %d.\n", *i2 );
*i3 = *i1 + *i2;
printf ( " Output I3 = %d.\n", *i3 );
}
/********************************************************************/
int int_add_func ( int *i1, int *i2 )
/********************************************************************/
/*
Purpose:
INT_ADD_FUNC adds two integers, returning the result as a function value.
*/
{
return ( *i1 + *i2 );
}
/********************************************************************/
void real_add_sub ( float *r1, float *r2, float *r3 )
/********************************************************************/
/*
Purpose:
REAL_ADD_SUB adds two real values, returning the result as an argument.
*/
{
printf ( "\n" );
printf ( "REAL_ADD_SUB:\n" );
printf ( " Input R1 = %f.\n", *r1 );
printf ( " Input R2 = %f.\n", *r2 );
*r3 = *r1 + *r2;
printf ( " Output R3 = %f.\n", *r3 );
}
/********************************************************************/
float real_add_func ( float *r1, float *r2 )
/********************************************************************/
/*
Purpose:
REAL_ADD_FUNC adds two reals, returning the result as a function value.
*/
{
return ( *r1 + *r2 );
}
/********************************************************************/
void double_add_sub ( double *r1, double *r2, double *r3 )
/********************************************************************/
/*
Purpose:
DOUBLE_ADD_SUB adds two double precision reals, returning the result as an argument.
*/
{
printf ( "\n" );
printf ( "DOUBLE_ADD_SUB:\n" );
printf ( " Input R1 = %f.\n", *r1 );
printf ( " Input R2 = %f.\n", *r2 );
*r3 = *r1 + *r2;
printf ( " Output R3 = %f.\n", *r3 );
}
/********************************************************************/
float double_add_func ( double *r1, double *r2 )
/********************************************************************/
/*
Purpose:
DOUBLE_ADD_FUNC adds two double precision reals, returning the result as an function value.
*/
{
return ( *r1 + *r2 );
}