-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidtriangles.c
More file actions
51 lines (39 loc) · 960 Bytes
/
validtriangles.c
File metadata and controls
51 lines (39 loc) · 960 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
48
49
50
51
//program that takes in three numbers and determines if it's a valid triangle
//Author: Joshua Steier
//Date: 4/13/2017
#include <stdio.h>
//need to make a type called bool
typedef int bool;
#define true 1
//so if true, it will print 1
#define false 0
//if false prints 0
//declare my function
bool is_valid(int a, int b, int c);
int main(void){
//let's declare variables and prompt input
int a;
int b;
int c;
printf("Please enter in a value for a: ");
scanf("%d", &a);
printf("Please enter in a value for b: ");
scanf("%d", &b);
printf("Please enter in a value for c: ");
scanf("%d", &c);
printf("%d\n", is_valid(a, b, c));
}
//let's make the function
bool is_valid(int a, int b, int c){
if (a + b > c){
return true;
}
if(c + a > b){
return true;
}
if(b + c > a){
return true;}
else{
return false;
}
}