favourite functions

Lets post functions that we have made or use. You can recreate a GE function, but I really want to see your own stuff. You should have a comment for each line so people understand it.
its a type of if statement that can be used inside another line. in the first set of brackets is a condition. like if(n > v). follow it with a ? mark. then the first result.. if the condition is true. then a : mark. next is the result if the condition is false. end with a semi-colon.
so use it like this.
s = (MAKSLANE > FUZZY) ? 1 : 2;
so s would equal 1, because GE is better than GM!otherwise, it would be = 2.
- Code: Select all
int Odd(int number) // finds out if a number is even or odd
{
return (number & 1) ? 1 : 0; // gives you a 1 if the number is odd, or zero if its even. I''ll explain this works below
}
its a type of if statement that can be used inside another line. in the first set of brackets is a condition. like if(n > v). follow it with a ? mark. then the first result.. if the condition is true. then a : mark. next is the result if the condition is false. end with a semi-colon.
so use it like this.
s = (MAKSLANE > FUZZY) ? 1 : 2;
so s would equal 1, because GE is better than GM!otherwise, it would be = 2.