Week 02 Tutorial Questions
Tutorial Overview First Hour:
- Part 1: Variables and constants
- Topics Covered: Declaring and initialising variables, data types, Calculating Values in Programs.
- Part 2: Calculating values in programs
- Topics Covered: Arithmetic, Logic, Comparitive operators.
- Part 3: Weird Data Types and Arithmetic
- Topics Covered: Complex Arithmetic expressions, order of operations.
- Part 4: Diagramming
- Topics Covered: Flow charts, If statements
Tutorial Overview Second Hour:
Tutorial Performance Hurdle Activity
- Part 1 If statements, scanf.
Part 1: Variables and constants
Objectives: Understand how to declare and initialise variables and understand the different data types. Understand how and when to use constants.
In this short activity we will recap the parts of a variables and how to declare, initialise and print variables working off of the starter code below:
// part1_variables
//
// This program was written by YOUR-NAME (ZID),
// on [DATE]
//
// This program calculates the area of a circle
#include <stdio.h>
int main(void) {
// 1. Declare the variables
// 2. Initalise the variables
// 3. Calculate the area of the circle
// 4. Print the result
return 0;
}
In this activity we will write a short program that takes input from the user to calculate the area of a circle. In this activity we will recap the parts of variables, how to declare, initalise and print variables and also revise when to use constants.
Part 2: Calculating Values in Programs
Objectives: Understand the different types of operators, and how to use them.
In this short section, we will review what tools we have for doing mathematics in our programs. This section will be completed quickly, to make sure we have time for the rest of the tutorial.
Part 3: Weird Data Types and Arithmetic
In this short section, we will review how you can store values in programs.
These are short arithmetic expressions we will use during this tutorial:
(7 / 2)
(3.0 / 2) + 1
'a' + 5
'F' - 'A' + 'a'
Part 4: Diagramming
Objectives: Understand Flowcharts, and how to use them to break down a problem.
In this section, we'll work on diagramming a small program.
Flow Charts:
We'll start by discussing the following flowchart:
any feedback?
Tutorial Overview Second Hour:
Part 1: Understand if statements, scanning and constants.
Tutorial Performance Hurdle Activity
In this activity, you'll be writing a program to determine whether someone is tall enough to ride a roller coaster.
How this activity will work:
- You'll work in pairs — your tutor will help you form groups of two.
- You should only use one laptop or a piece of paper per group.
- Once your group finishes writing a solution, pair up with another group.
- One person from your group should discuss your solution with a member of the other group.
- Compare how you approached the problem and see if there are differences or improvements.
Your task: Write a program that:
- Scan in the users height.
- If the height is 0 or less, it should print an error message,
- If the height is below the minimum height, it should print a message telling the user they are not tall enough to ride,
- If the height is above the minimum but below the ride alone threshold, it should print a message telling the user they can ride with an adult,
- If the height is or is above the ride alone threshold, it should print a message telling the user they can ride.
For the purposes of this activity the minimum height to ride if 100cm
and the minimum height to ride alone is 160cm
.
// part5_roller_coaster
//
// This program was written by YOUR-NAME, ZID
// on [DATE]
//
// This program:
// 1. Scans in the users height.
//
// 2. If the height is 0 or less,
// it should print an error message
//
// 3. If the height is below the minimum height,
// it should print a message telling the user they are not tall enough to ride
//
// 4. If the height is above the minimum but below the ride alone threshold,
// it should print a message telling the user they can ride with an adult
//
// 5. If the height is or is above the ride alone threshold,
// it should print a message telling the user they can ride.
#include <stdio.h>
int main(void) {
return 0;
}