### Kinda new to bool.

sup folksss.

Im trying out new stuff and I'm learning bools rn.
Im at the begginer start so I don't know the fancy stuff or that.

Im given 2 numbers
5 8 ( From 5 to 8) (a,b)
The first bool asks that I need to check trough those numbers if any triangles can be made.
The second bool asks me if the triangle is miscellaneous triangle ( All of the sides have to be diff I remember correctly)
And lastly the sum which I know how to probabbly :DDD.

5 6 7 14.70
5 6 8 14.98
5 7 8 17.32
6 7 8 20.33
 ``1234567891011`` ``````bool Triangle ( int a, int b) { for ( int i = a; i < b;i++) if ( a + b > c) return true; else return false; // I dont know what im doin. First time with this stuff. } bool Triangle1 ( int a, int b) { if ( a != b && b != c && c != a) return true; else return false;``````

I actually dont know what to do because our teacher flew trough it so fast I didnt understand it
P.S I know I did that so badly xDDDD
All help would be appreaciated. :))
Last edited on
All a boolean value does is indicate a truthy value. You use it to answer a yes/no question.

For example, if you want to know whether a shape is a triangle or not, you could have a function that looks like this:

 ``1234567`` ``````bool is_triangle( double a, double b, double c ) { // is the sum of the two smaller sides < the largest side? if (a > b and a > c) return b + c < a; // if a is the largest side if (b > c) return a + c < b; // if b is the largest side return a + b < c; // else c is the largest side }``````

`can_a_triangle_be_made`
`is_a_misc_triangle`

Etc.

You use it in a conditional statement:

 ``123`` `````` if (is_triangle( 3, 4, 5 )) ... // answer is YES if (is_triangle( 1, 2, 3 )) ... // answer is NO if (is_triangle( 2, 4, 8 )) ... // answer is NO ``````
Topic archived. No new replies allowed.