Professional Documents
Culture Documents
C M Week 1: Introduction
Oct. 13, 2020
Target Audience
Everyone.
0 1
14
Programming is an asset that every engineer and every scientist
should have for a successful career
P
In this room: students enrolled in EEE, MCH, any others?
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 2 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
Course Coverage
Fundamentals of programming in C
0 1
Understand computer programming fundamentals
14
Upon successful completion of this course, you’ll be able to:
P
Implement the algorithm using the C programming language
Practice and improve programming on your own
C M
Have the foundation that is essential for you to build on in your future
courses/internships/projects
Tentative Outline
Week
1)
2)
Date
Oct. 13/14/15
Oct. 20/21/22
Subject
0 1
Course outline, introduction to computer systems
Basics of C programming; data types, assignments
4
Oct. 27/Nov.
3) Operators and conditional statements
4/Nov. 5
1
4) Nov. 3/11/12 do-while/while/for loops; switch statement
5) Nov. 10/18/19 Nested loops
6) Nov. 17/25/26 Functions
7)
8)
Nov. 24/Dec.
2/Dec. 3
Dec. 1/9/10
Midterm exam
Functions (cont’d)
P
9)
10)
11)
12)
13)
Dec. 8/16/17
Dec. 15/23/24
Dec. 22/30/31
Dec. 29/Jan.
6/Jan. 7
Jan. 5/13/14 C M Arrays
Pointers
Passing pointers to a function
Searching in arrays
Strings, string operations
14) Jan. 11/18/19 Semester recap
Resources
(optional) Books:
0 1
14
C How to Program, Deitel & Deitel, Prentice Hall
The C Programming Language, Kernighan & Ritchie, Prentice Hall
P
References
http://www.cprogramming.com/
M
www.stackoverflow.com/
C
Additional online resources announced via itslearning
Lectures
P
C M
Office Hours: Fridays 9:30-10:30, Online on MS Teams
Attendance
0 1
14
Attendance is mandatory (will take attendance through MS Teams)
Grading
A. Midterm [30%]
Covering all topics until Week 7.
0 1
B. Final [40%]
14
Cumulative final exam covering all topics. Date and time will be announced at the
P
end of the semester.
C. Quizzes [10%]
in total.
Please Do’s
0 1
4
Check class website for updates/announcements/syllabus
1
Spend at least 1 hour every week on this class (excluding lecture time!)
Suggested readings, course notes review
P
More hours will be necessary before quizzes/midterm/final
Ask questions when unclear. We’ll discuss in class, you’ll help your
classmates too!
C
Attend the exams at all cost
M
Make-up for Midterm or Final will be available only if you supply a formal
paperwork
0 1
14
Cheating and plagiarism are very serious offenses and will be
penalized accordingly by the university disciplinary committee.
Copying answers on exams, homeworks, lab works
Using prohibited material on exams
P
Lying to gain any type of advantage in class
C M
Modifying graded material to be re-graded
Causing harm to colleagues by distributing false information about an
Student Input
0 1
Any questions?
Anything you would change?
14
Any topics you would particularly like covered?
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 11 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
What is a Computer?
0 1
Hardware (physical components)
Processor
14
P
Memory
I/O devices (keyboard, monitor, mouse)
C M
Executes very simple instructions
Executes them incredibly fast
Must be programmed – the software determines what a computer
actually does
0 1
14
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 13 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
Software Applications
0 1
Most engineering activities
involve software
e.g. aircraft communication,
14
P
telecommunications, energy
monitoring, Mars rovers,
chip manufacturing
Other sectors
C
banking, automobiles,M
defense, bioinformatics
How to Program?
0 1
Solution -- find a solution to the problem
14
Algorithms -- express the solution as (a set of) algorithm(s)
P
Programming -- implement these algorithms as a set of instructions that
a computer can follow (source code)
C M
Program using a programming language, e.g. C
Algorithms
0 1
Must satisfy:
14
non ambiguity -- the instructions must be interpretable in a unique
way by whomever is executing them
P
executability -- it must be possible to execute each instruction (in a
finite amount of time) given the available resources
M
finiteness -- the execution of the algorithm must terminate in a finite
amount of time for each possible set of input data
C
First we design an algorithm, next we code it in the selected
programming language
Example
0 1
4
Problem: We want to know the age difference between two persons
C M
2. Subtract second age from first age
0 1
Algorithm revised for inputs:
1. Get the ages from user.
14
P
a. Ask user for first age.
b. Ask user for second age
M
2. Subtract the smaller age from the greater one
a. If first age is greater than second, subtract second age from first age
C
b. Otherwise, subtract first age from second age
3. Print the result.
14
P
Need to consider the initial conditions (initial state)
C M
Consider rare conditions (Edge Cases)
Presenting Algorithms
0 1
14
P
Flowchart
C M Pseudocode
Flowcharts
C M
All flowcharts begin with Terminal or
Process symbols
All boxes must be connected with arrows
Decision symbols have 2 exit arrows
(TRUE/YES and FALSE/NO)
0 1
14
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 22 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
Loops on a Flowchart
Two examples:
0 1
14
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 23 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
Pseudocodes
0 1
mathematical notation
14
The algorithm is outlined using English statements and compact
P
intended for human reading rather than machine reading
C M
Put one command on a line
Place any important words in bold
Start from the top and work toward the bottom
Separate processes with spaces to form modules
Example Pseudocode - 1
0 1
14
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 25 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
Example Pseudocode - 2
0 1
14
P
C M
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 26 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
0 1
Initialize sum=0 (PROCESS)
Ask the user for two numbers
14
P
(I/O)
M
the result in sum (PROCESS)
Print sum (I/O)
C
CMP1401: Introduction to Programming with C Week 1 – Oct. 13, 2020 27 / 31
Course Goals Logistics Student Input Computers Algorithms Recap
C
How can you change this algorithm and get the same solution?
P
it to sum 5. if count = 5 then
Increment count 6. output sum;
C M
If count is less than 5, take
end
go to Step 2;
0 1
4
Take a number from user
Summary
0 1
Algorithms are the first step to solving a problem
14
Algorithms can be represented as a flowchart or pseudocode
P
There are certain rules that must be followed in designing algorithms
M
There is usually more than one way to solve a problem
Multiple different algorithms can solve the same problem
C
Next week: we dive in to programming!