aboutsummaryrefslogtreecommitdiffstats
path: root/test/gourdinl/c/funcs.c
blob: 49e610d6601cdf6180179a4d2eed99a4b2fd4af0 (plain)
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
/* funcs.c  -- More examples of functions
 */

#include <stdio.h>

int getint(void); /*It prompts user to enter an integer, which it returns*/

int getmax(int a, int b, int c); /*It returns value of largest of a, b, c*/

/* Main program: Using the various functions */
int main (void) {
  int x, y, z;

  x = getint();
  y = getint();
  z = getint();
  printf("The largest of %d, %d, and %d is %d\n", x, y, z, getmax(x,y,z));
}

int getint(void) {
  int a;

  printf("Please enter an integer > ");
  scanf("%d", &a);
  return(a);
}

int getmax(int a, int b, int c){
  int m = a;

  if (m<b)
    m = b;
  if (m<c)
    m = c;
  return(m);
}