0% found this document useful (0 votes)
61 views

Lecture 1

This course introduces students to computing science concepts and programming using C/C++. It covers fundamental topics like algorithms, data structures, and good coding practices. Students will complete assignments, labs, a midterm and final exam to assess their understanding.

Uploaded by

Agrim joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Lecture 1

This course introduces students to computing science concepts and programming using C/C++. It covers fundamental topics like algorithms, data structures, and good coding practices. Students will complete assignments, labs, a midterm and final exam to assess their understanding.

Uploaded by

Agrim joshi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

CMPT 125: Introduction to Computing

Science and Programming II


Fall 2023

Week 1: Course Intro, Introduction to C


Instructor:Victor Cheung, PhD
School of Computing Science, Simon Fraser University

© Victor Cheung, 2023


Spagetti
Complicated. Hard to understand.

The Pasta
Theor y of
Programming Lasagna
– By Raymond J. Understandable. Layered.
Rubey

Ravioli
Modular. Nourishing

Source: https://www.gnu.org/fun/jokes/pasta.code.html
It Is Important to Write Good Code

• Easy to maintain
• If you need to change something you know where & how
• Gets the job done & done well
• Write working code effectively and efficiently
• Easy to share
• Reusable, adds value, engaging, and empowering

Takes time and practice, but worth it!

Source: https://xkcd.com/844/
What You Will Learn in This Course

• Design & implement solutions to problems using C/C++


• Explain, analyze, & compare algorithms in terms of performance
• Describe & utilize fundamental computing science concepts
• Maintain good coding practice and style

4
What This Course Is Really About

• Main objective is to learn about the concepts of CS concepts


Computing Science and Programming
• And a little bit of good coding practice C/C++
(as a means)
• C/C++ is just a means to practice it
• You might have learned other languages by yourself or Programming
tools
through other courses
Development
environments
• Use tools to work with C/C++ source code
• Makefiles and IDEs, also a bit of Unix/Linux

5
How This Course Is Related to Your Labs

• CMPT 125 has lectures and labs


• Lectures talk about theories informing practice in labs
• Labs involves practice informing theories in lectures CS concepts CS concepts
• You can also ask questions about
C/C++
assignments in labs How the
syntaxes &
code works
uses
C/C++ and
Programming
some code
constructs
management

6
Lectures Labs
Lecture Over view

• Logistics
• Expectations
• How to do well in this course
• Concepts in Computing Science
• Introduction to C

7
Logistics – Your Course Instructor

• Victor Cheung
• PhD in System Design Engineering, University of Waterloo
• Research in interaction & interface design, tangible systems, emerging technologies
[email protected]

8
Logistics – Course Info

• Lectures: Wednesdays 1:30p – 2:20p (SSCB 9200), Fridays 12:30p – 2:20p (SSCB 9200)
• Labs: Tuesdays 8:30a – 9:20a / 9:30a – 10:20a / 10:30a – 11:20a / 11:30a – 12:20p (ASB 9838N)
• Office Hours: TBA, check SFU Canvas
• Teaching Team
When sending your email:
• Instructor: Victor Cheung, PhD | Email: [email protected] • Use your SFU email
• In the subject line begin with "CMPT 125 D100:"
• Teaching Assistants:
and then topic of your message. For example,
• Kajori Roy | Email: [email protected] CMPT 125 D100: Missed Assignment 1
• In the body of your message, include your full
• Risheek Sood | Email: [email protected]
name, SFU ID, 9-digit student number and section
• Naina Thapar | Email: [email protected] number
• David Ricardo Wong | Email: [email protected]
• Help email that reaches all the teaching personnel: [email protected] 9
Logistics – Readings

• We’ll use parts of these books and a collection of online readings


• Seacord, R. C. (2020). Effective C. No Starch Press. Online access (requires SFU login): https://sfu-
primo.hosted.exlibrisgroup.com/permalink/f/usv8m3/01SFUL_ALMA51348448870003611
• Ullman, L. E., Liyanage, M., & Safari Tech Books Online. (2005). C programming (1st edition.). Peachpit Press. Online access
(requires SFU login): https://sfu-primo.hosted.exlibrisgroup.com/permalink/f/usv8m3/01SFUL_ALMA51188910730003611
• Good reference for C/C++:
• http://cplusplus.com/
• https://en.cppreference.com/
• https://www.programiz.com/c-programming

*Instructor’s notes prevail when there is a conflict. Contact the instructor when in doubt 10
Logistics – Course Materials

• All materials (or links to them) are on Canvas (https://canvas.sfu.ca/courses/80226)


• We will also use CourSys (https://coursys.sfu.ca/2023fa-cmpt-125-d1/) for submissions
• No recordings will be available. IT service might record audio automatically, email me if you have a valid reason to miss a lecture and
I’ll see what I can do (but generally speaking if you miss a lecture you miss a lecture, decision is yours)
• Use the Discussion forums to ask questions or give suggestions
• We will be monitoring them to give you answers in a timely manner
• We might remove your post if it has solutions or anything that might lead to plagiarism or cheating, or if it is inappropriate
• Software tools
• You may use any tools to write your code to start (e.g., Replit, online-ide, Atom,VS Code)… BUT
• Before you submit connect or go to CSIL machines to develop & test your code (we’ll use that to mark your code)
• If your submitted code doesn’t compile/run there, you get 0 marks
11
Logistics – Assignments/Labs/Exams

• Tentative:
• Assignment 1/2/3/4 (30%) | due on Sep 29/ Oct 13/ Nov 10/ Dec 1
• Lab Attendance/Demo (10%): best 10 out of all available labs
• Midterm Exam (25%): cumulative and include all materials covered thus far | on Week 9 during the 2-hour lecture
• Final Exam (35%): cumulative and include all materials covered thus far | TBA
• Assignment late penalty: 10% per calendar day (each 0 to 24 hour period past due), max 2 days late
• The instructor will do his best to accommodate within reason, but will have the final say
• Contact the instructor as soon as possible
• More details as the due dates approach

12
Logistics – General Etiquette

• Be on time (if you are late, come in quietly)


• Ask if you have questions (raise your hand or ask after the lecture)
• Treat all messaging platforms (e.g., discussion forums, emails) professionally
• Email using your SFU account, put “CMPT 125 D100” in the title
• Include your full name and student ID in your signature
• Use full sentences and no textisms like “b4”, “w8”, “that’s gr8”, “thx 4 BN aQr8”
• Fun read: An Analysis of Language in University Students’ Text Messages
by Lyddy et al. 2013 https://doi.org/10.1111/jcc4.12045
• Check it frequently – if I need to contact you directly this will be where I do it

13
Things That You Should Know (Doesn’t have to be in C)

• Variables
• Data types (integer, float, char, string, boolean)
• Lists/arrays
• Basic I/O
Don’t worry if you
• Conditionals (if/if-else/if-else if-else) only remember some,
• Loops (for, while)
• Functions, parameter passing
we’ll revisit them
• The design → test → debug cycle

14
Examples of Things You Should Know

• You should be comfortable solving the following problems (in Python, Java, …etc.)
• Write a function that gets a string and decide if it is a palindrome. For example:
is_palindrome(“ABCDCBA”) needs to return True
is_palindrome(“ABCDB”) needs to return False
• Write a function that gets a string and finds the longest substring that is a palindrome. For example:
longest_substring_palindrome(“ABCDBAABBA”) needs to return “ABBA”
longest_substring_palindrome(“ABCDB”) needs to return “A”
• Write a function that gets a list of digits, and outputs a string containing the largest number you can writing
using these digits. For example:
max_number([1,2,8,8,1,1, 0]) needs to return “8821110”

15
Should You Take This Course?

SHOULD SHOULD NOT

• If you want to learn about Computing Science and • If you are here only to learn C/C++
what it is about
• If you do not want to write code
• If you want to become better in designing and
• If you are looking for an easy A
writing your code
• If you have some programming background and
want to learn about C/C++

16
Who Will Do Well in This Course?

• Attend classes and pay attention Looking for information online


• Participate in discussions • Check course notes first!
• Then check readings & course materials
• Make progress on assignments/projects regularly • Google/StackOverflow/YouTube may seem
useful but can also contain advanced code
• Get advice from the instructor/TAs when needed that will be more confusing than helpful…
proceed with caution
• Follow instructions carefully on assignments
• Regularly review readings / course notes (and find other reading materials)
• Put in the extra effort in maintaining your code

• For grading policies refer to the Course Policies page on Canvas


17
Academic Integrity

• No plagiarism
• All referenced work must be appropriately cited, including code, websites, images, figures, and graphs
• Never directly copy & paste and treat it as yours
• You must write your own code (we will use software, e.g., MOSS, to check)
• No cheating
• All assignments/exams must be your own work (team’s work if it is a team project)
• It is ok to discuss with others for assignments, but you have to write your own work. Mention whom you have talked to if necessary
• All incidents will be reported according to SFU policy
• http://www.sfu.ca/policies/gazette/student/s10-01.html
• Understand what is considered cheating and what is not at SFU’s Academic Integrity Tutorial (https://canvas.sfu.ca/courses/56136)

18
What about ChatGPT (or Other AI Tools)?

• I know they exist (and I use them sometimes), they work like helpers/tutors
• General rule-of-thumb: you can use them, but DO NOT copy (that’s academic dishonesty)
• Be aware of the risks:
• …
• Keep this in mind:
• You can’t use them in exam
• Not only you have access to them

*different instructors might have different policies, check with them


19
You Are An Adult Now

• You are not a child anymore and you are responsible to your own decisions & actions
• Manage your time
• Plan ahead for deadlines, get enough rests, do stuff that you enjoy
• Be proactive
• Look up information beyond what’s in the slides, ask questions when in doubt
• We might not answer your questions if we have already provided answers to them
• Do honest work
• All the academic integrity information are available and you can’t claim you don’t know about them

20
Expectation Management

• 125 is very different and the pace is much faster than 120 or your other intro courses
• It combines programming, CS concepts, and labs all in one course
• You are expected to write a lot of code
• Expect to write multiple files, each about 200-300 lines of code
• You only have 2-3 weeks between each assignment, some build on top of the previous
• You are expected to do your own practice and read additional materials as needed
• We will provide some post-lecture activities, practice exercises, complementary readings, but in
the end you need to help yourself
21
Questions?
If you have questions later in the course, feel free to ask them in the Discussion on Canvas

22
Let’s start with Some Concepts

23
Some Core Concepts in Computing Science

• Algorithms – a sequence of instructions to complete a task or solve a problem


• There are usually many different ways to complete the same task or solve the same problem (hence different algorithms)
• The clearer each step the better (there are other ways to make an algorithm better, e.g., faster, requires less space)
• Programming – the action of communicating an algorithm to computers using a specific language
• Here we use C (and some C++)
• Data structures – specific ways for computers to store a collection of data for better management (e.g., insert,
remove, search)
• Different structures have different properties and trade-offs (e.g., faster in some operations slower in others, takes more space)
• Most are independent from programming languages (i.e., you can implement them using languages other than C/C++)

24
The Compilation Process (1)

• Interpreted programming language (e.g., Python, Javascript)


• You implement algorithms into code, interpreter runs one instruction at a time when executing the program

Interpreter
• Algorithm • Running program
• Source code
You Output

25
The Compilation Process (2)

• Compiled programming language (e.g., C/C++, Java)


• You implement algorithms into code, compiler converts code into machine code (instructions),
computer runs one instruction at a time when executing the program

Compiler Output
• Algorithm • Machine code
• Source code • Running
program
You Computer

26
Interpreted VS Compiled

INTERPRETED COMPILED

• Errors are caught only when the interpreter is • Some errors can be caught during compile time so
trying to run them they can be fixed earlier
• Can test the code quicker because the interpreter • Takes a bit longer to get the code running because
directly runs it of the compilation process
• Program is less optimized because the interpreter • Program often performs better because some
needs to convert the code into machine code optimizations for the operating system and
internally every time architecture can be done by the compiler

27
C is within the top 3 most popular (used/searched/taught) programming language
28
Something about C

• C was developed by Dennis Ritchie between 1972 & 1973 at AT&T Bell Labs
• Designed to map to typical machine instruction – so the source code can easily be compiled & optimized,
but also sometimes hard to understand
• Widely used to implement operating systems, computationally intensive programs, computer graphics
• Provides low-level access to system memory via pointers – highly flexible but can cause strange and
sometimes harmful impacts to the system

29
Let’s Take A Look at A C Program

What would you


do if you want the
This allows you to use program to print a
external code (library) different sentence?

What happens if
you want to print
Lines 3-7 is what we
more sentences?
call the “main function”,
which is the entry
point of a C program

30

*Refer to the “Accessing CSIL machines remotely” page on Canvas to learn about different ways to connect to CSIL
Homework!

• Read Ch. 1 of the Effective C book


• Use gcc instead of cc to compile your source code in CSIL machines
• Investigate the difference between puts and printf
• Do the “Tell Us about You” survey on Canvas
• Find out how to connect to a CSIL machine (CLI and RDP)
• Get yourself an access fob to CSIL (our labs will take place there starting next week)
• Write the “Hello World” program from scratch without referring to any notes
• Try printing something other than “Hello World!”, then try printing more than one sentence
• For fun, watch this video I made: https://www.youtube.com/watch?v=sQa1HHTMmmQ

31

You might also like