A file in ‘Franc C’ always starts with: “Bonjour,” followed by an empty line.
Politeness is very important, and we wanted ‘Franc C’ to express a proper and classic language, not a crappy street language. We promise you will learn the “bien parlé” by using ‘Franc C’
In order to declare a function, you must specify:
J'aimerais définir le bloc répondant au nom de <function_name>,
where is the name of the function
de type de retour entier naturel,
for the function to return an integer.
de type de retour booléen,
for the function to return a boolean.
de type de retour nul,
if the function does not return anything. (void function)
A parameter, in Franc C, is defined the same way as other programming languages : Those are variables that must be passed when the function is invoked for it to use them.
necéssitant comme entrée :
- <variable_name1>, de type <type>
- <variable_name2>, de type <type>
...
;
You can include as many parameter as you want as long as they do not share the same name.
Parameters are obviously optional. If the function does not take any parameters, you must specify :
nécessitant comme entrée : ;
Variables created and used inside a function, in Franc C, are defined in the function definition. Since Franc C is a very verbose language and uses a lot of words, creating variables at the top of the function makes it a very good way to clearly see them.
Such variables are being declared the following way :
contenant les variables :
- <variable_name1>, de type <type>, valant <value>
- <variable_name2>, de type <type>, valant <value>
;
Just like parameters, variables must not share the same name. A parameter and a variable can not share the same name either.
This forces every single created variable to have a default value.
If the function does not use any variable, you must specify :
contenant les variables : ;
A function declaration ends with
représenté par le code <logical_connector>.
What must follow this declaration is the body of the function, which is what will be executed when the function is invoked.
In Franc C, what can be executed inside a function is being refered as an ‘instruction’.
Those are the available instructions that you can execute inside a function :
You can, at any time, change the value of a variable the following way :
J'aimerais que <variable_name> prenne la valeur <computables>.
or
<variable_name> prends la valeur <computables>.
Execute a block of code only if a specific condition was met. It can be defined the following way :
Si <computables>, exécute le texte :
<more_instructions>
Merci.
You can also execute a block of code if the condition wasn’t met the following way :
Si <computables>, exécute le texte :
<more_instructions>
; sinon, exécute le texte :
<more_instructions_2>
Merci.
Invoke another function inside a function, you can also store its result in a well-defined function variable.
J'invoque le bloc <function_name>.
If the function that is being invoked takes parameters, they must be specified the following way :
J'invoque le bloc <function_name>, avec les paramètres <computables>, <computables>, <computables>.
You must not give to a function more parameters than it takes.
In order to store the result of a function, while still giving parameters :
J'invoque le bloc <function_name>, et j'assigne la valeur de retour à la variable <variable_name>, avec les paramètres <computables>, <computables>, <computables>.
However, if you do not want to give any parameter :
J'invoque le bloc <function_name>, et j'assigne la valeur de retour à la variable <variable_name>.
The only type of loop that is currently implemented in ‘Franc C’ are the ‘while’ loops.
A loop allows to execute a block of code until a condition cannot be met anymore.
Tant que <computables> exécute le code ci-après :
<more_instructions>
Merci.
During the execution of the function, you can return at any time a value. Returning a value will cause the function execution to stop.
The only condition to return a value is that the function must not be of type “nul”.
Enfin, renvoie <computables>.
If the function does not return anything (‘nul’ function), you can still stop the execution at any time.
Enfin, sors du bloc.
This works only if the function is a ‘nul’ function.
This instruction is used to display either a text, or the result of a computation in the screen.
To display a computation :
Affiche <computables>.
This will display the character corresponding to the result on the screen. (E.g): ‘Affiche 10.’ will display ‘\n’.
However, if you want to display a text :
Affiche « Meow ».
This will display the text ‘Meow’ on the screen.
You must always end your Function Body with a ‘Merci.’.
The main function is where the program starts. Therefore, its defintion must be clearly different from the other functions.
Such functions are being defined the following way :
Bonjour,
En sachant que les variables principales sont :
<variables>
; pourrais-tu s'il te plaît commencer la lecture ici ?
<instructions>
Merci d'avance,
Cordialement,
<family_name>
<name>
A main function does not take any parameter. Therefore, no parameter definition must be done. The value being returned in the main function represent the exit status of the program. If no value was being returned, the program exists by default with a status code of ‘0’.