q
This commit is contained in:
@@ -338,10 +338,12 @@
|
|||||||
<code class="cblock"><pre>x = (a > b) ? 1 : 0;</code></pre>
|
<code class="cblock"><pre>x = (a > b) ? 1 : 0;</code></pre>
|
||||||
This means that if a is greater than b, assign x with 1. If a is not greater than b, assign x with 0. The ternary operator however needs the values in the if and else part to be of the same type. If they are not, the program will fail to compile.
|
This means that if a is greater than b, assign x with 1. If a is not greater than b, assign x with 0. The ternary operator however needs the values in the if and else part to be of the same type. If they are not, the program will fail to compile.
|
||||||
</p>
|
</p>
|
||||||
<h2> id="functions"></h2>
|
<h2 id="functions">Functions</h2>
|
||||||
|
<h3 id="functions_basics">I. Basics</h3>
|
||||||
<p>
|
<p>
|
||||||
A function is a wrapper to easily reuse code and improve readability of your program. The function signature contains the return type, the identifier of the function, and the parameters that the function requires. The function contains statements within the curly braces. Finally, the function returns a value which has a type indicated in the function signature.
|
A function is a wrapper to easily reuse code and improve readability of your program. The function signature contains the return type, the identifier of the function, and the parameters that the function requires. The function contains statements within the curly braces. Finally, the function returns a value which has a type indicated in the function signature. Proper functions also have one intended use. If a function contains more than one use, it is a good idea to split them up.
|
||||||
<code class="cblock"><pre>type name (parameters) {...}</pre></code>
|
<code class="cblock"><pre>type name (parameters) {...}</pre></code>
|
||||||
|
Functions must be defined before they are called. That is, the definition must come before any reference to using the function. A function call is done by referencing the name of the function as a statement. For example <code>my_function(1,2,3);</code> is a call to <code>my_function(int a, int b, int c) {...}</code> with the parameter values <code>a = 1, b = 2, c = 3</code>.
|
||||||
</p>
|
</p>
|
||||||
<h2 id="other">Other Topics</h2>
|
<h2 id="other">Other Topics</h2>
|
||||||
<h3 id="other_string-manipulation">String Manipulation</h3>
|
<h3 id="other_string-manipulation">String Manipulation</h3>
|
||||||
|
|||||||
Reference in New Issue
Block a user