A4 - Introduction to C
There is a great online introduction to this programming langauge here.
This assignment will cover up to the section C Data Types, subsection Decimal Precision.
Setting up Your Environment
Please run the update, which will add a subfolder C to your Local folder.
In there you will find two sample files, hello.c and math-formulas.c.
Rather than using VS Code for editing your C files, we're going to use a program called CodeBlocks which is already installed in our lab and requires no configuration.
Try the following:
- Open Codeblocks (the easiest way is to probably just search for it)
- You'll get a dialog box about choosing a compiler. The only available one will be GNU GCC, which you can make the default and then click OK.
- Any option you select in the file associations box that pops up should be fine.
- Go to File --> Open and navigate to
hello.c - The quickest way to run it is to press the F9 key on your keyboard.
- You can repeat the process with
math-formulas.ca
Sample Files
Look through and run the files hello.c and math-formulas.c, and try to get a handle on how all the code works.
Your Task
Add three more formulas to the math-formuals.c file.
At least one of them should use integer data types, and at least one of them should use float data types.
To save you time while you are developing this, consider commenting the calls in the main function to the
functions you are not currently working on.
You can find some ideas for math formulas to use here.