Skip to content
Permalink
Browse files
Merge branch 'master' of github.coventry.ac.uk:ac0745/4003CEM-intro
  • Loading branch information
ac0745 committed May 12, 2020
2 parents 191a5c7 + ebc8d3e commit 08ec840cba22822a1759efefc4a9e53f9da2b814
Show file tree
Hide file tree
Showing 10 changed files with 1,931 additions and 0 deletions.
@@ -16,3 +16,9 @@ Makefile
cmake_install.cmake
install_manifest.txt
CTestTestfile.cmake

.guides/assessmentsAnswers.json
.guides/metadata.json
.guides/styles.css
.guides/prevname
.settings
@@ -0,0 +1,244 @@
[
{
"type": "test",
"taskId": "test-3144866421",
"source": {
"name": "lab_hello",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_hello",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": [
{
"type": "terminal",
"panelNumber": 1,
"content": ""
}
]
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-4131644210",
"source": {
"name": "lab_welcome",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_welcome",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-3549672414",
"source": {
"name": "lab_even",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_even",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-4277614632",
"source": {
"name": "lab_age",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_age",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-2091886658",
"source": {
"name": "lab_leap",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_leap",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-2154651529",
"source": {
"name": "lab_fibonacci",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_fibonacci",
"arePartialPointsAllowed": false,
"timeoutSeconds": 80,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": [
{
"type": "terminal",
"panelNumber": 1,
"content": ""
}
]
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-689651608",
"source": {
"name": "lab_reverse",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_reverse",
"arePartialPointsAllowed": false,
"timeoutSeconds": 40,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": []
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
},
{
"type": "test",
"taskId": "test-2636540227",
"source": {
"name": "lab_sqrt",
"showName": true,
"instructions": "",
"command": "Testing/helper/codiotest test_sqrt",
"arePartialPointsAllowed": false,
"timeoutSeconds": 80,
"guidance": "",
"showGuidanceAfterResponse": false,
"points": 1,
"oneTimeTest": false,
"metadata": {
"tags": [
{
"name": "Assessment Type",
"value": "Advanced Code Test"
}
],
"files": [],
"opened": [
{
"type": "terminal",
"panelNumber": 1,
"content": ""
}
]
},
"bloomsObjectiveLevel": "",
"learningObjectives": ""
}
}
]
@@ -0,0 +1,35 @@
{
"name": "4003CEM - Cpp intro",
"children": [
{
"title": "Compiling",
"id": "67c11d3b-3846-e989-a5ae-db83cb2b1c5a",
"pageId": "67c11d3b-3846-e989-a5ae-db83cb2b1c5a",
"type": "page"
},
{
"title": "Basic programs",
"id": "f6da9b9a-75ff-c265-d802-cc51d4ae52f4",
"pageId": "f6da9b9a-75ff-c265-d802-cc51d4ae52f4",
"type": "page"
},
{
"id": "cb5ced50-387a-a367-a180-64d7f5204a2b",
"title": "Header files",
"pageId": "93508c1a-0d05-3f85-4b99-08ee7a8521a0",
"type": "page"
},
{
"id": "1e0f681b-3115-c051-e090-51bb161ab7e5",
"title": "More tasks",
"pageId": "0edfe78d-7c66-c15f-daff-934c594ce83e",
"type": "page"
},
{
"id": "d79305cb-91e7-82b8-5bcc-49795089d806",
"title": "Advanced",
"pageId": "abf8f558-a3df-9a10-9e70-61f270919484",
"type": "page"
}
]
}
@@ -0,0 +1,25 @@
<h2 style="color:red">Times table</h2>
Use nested for loops to have C++ print the complete 5 × 5 table.
See if you can make it look like the one below.
<pre>
* | 1 2 3 4 5
--+---------------
1 | 1 2 3 4 5
2 | 2 4 6 8 10
3 | 3 6 9 12 15
4 | 4 8 12 16 20
5 | 5 10 15 20 25
</pre>

<h2 style="color:red">Arrow</h2>
Create a function which takes as input two numbers, a width and a trunkLength ,and then prints out a tree shape like below (this one has width 9 and trunk length 3). Try and solve it twice - once with a for loop and again with a while loop.
<pre>
*
***
*****
*******
*********
***
***
***
</pre>
@@ -0,0 +1,14 @@
<h2 style="color:green">lab_welcome</h2>

For this task you need to complete and compile the `lab_welcome.cpp` file.
The program should print ``Welcome to 4003CEM!`` on a new line.

{Check It!|assessment}(test-4131644210)

<h2 style="color:darkorange">lab_fibonacci</h2>
Write and call a function called fibonacci in the lab_fibonacci.cpp file.
The function should print the first 40 elements in the fibonacci sequence.
The sequence should start 0, 1, 1, 2 ....
Each element should be printed on a new line.

{Check It!|assessment}(test-2154651529)
@@ -0,0 +1,37 @@
# 4003CEM-intro

There are multiple C++ compilers available and each works differently to all the others.
This means that the commands that you learn for `g++` will not work in Visual studio or Clang for example.

# Basic
The basic g++ compile command is `g++ [YOUR CPP FILE]`.
Where `[YOUR CPP FILE]` should be replace with the actual filename.
For example if you were trying to compile a file called `example.cpp` then the command would be `g++ example.cpp`.

### C++ versions
However there is a problem with this. C++ has undergone multiple revisions over its history and there are multiple different versions of C++ containing different abilities and features.
The command we have just seen will compile our .cpp file in whatever the default version of C++ happens to be on that machine; this may not be the version of C++ that we actually want.

To compile our code with a specific C++ version we would use the following format `g++ -std=[VERSION] [YOUR CPP FILE]`.
In 4003CEM the C++ version that we are using is C++14 and so the command we would enter would be
`g++ -std=c++14 example.cpp`

### Setting the executable name/location
By default our code will be compiled into an executable file named `a.out` which is not particuarly meaningful.
If we want our executable to be called something difference then we need to use the `-o` option, `g++ [YOUR CPP FILE] -o [EXECUTABLE NAME]`.
So the final command to would look something like this `g++ -std=c++14 example.cpp -o bin/example`.

### Running the executable
Once the code has been compiled into an executable then that can be run by simply typing the name of the file into the terminal.
Either giving the absolute path to the file i.e. `/home/codio/workspace/bin/example`.
Or by giving the relative path, i.e. `bin/example` ( or `./example` if the executable is in the same directory).

<h2 style="color:green">lab_hello</h2>
Compile the lab_hello.cpp file into an executable called "hello".
This executable should be placed in the 'bin/' directory.
You will need to use `g++` to compile the correct .cpp file into an appropriately named executable.
You may need to create the `bin/' directory first.
{Check It!|assessment}(test-3144866421)
@@ -0,0 +1,14 @@
# .h .cpp
Whilst it is possible to write your entire program is a single .cpp file, this is a bad idea.
In 4000CEM we saw how it was possible to separate our programs into multiple files in order to make our code easier to manage and to test.
We are going to be doing the same thing in 4003CEM.
In python we used the `import` keyword to include another .py file into our programs.
In C++ we use `#include` to include .h files into our program.
The situation is more complicated than this in reality but we don't care right now and will explain it in a later session.

<h2 style="color:green">lab_even</h2>
Write a function called is_even in the lab_even.h file which has a single integer argument.
The function should return a boolean, true if the argument is an even number and false otherwise.

{Check It!|assessment}(test-3549672414)

0 comments on commit 08ec840

Please sign in to comment.