You are on page 1of 29

CS 103

Introductory Programming for

Engineers and Scientists
Summer 2015


Slides will be available on Blackboard after class

Course Staff: Instructor

Dr. Robert Tairas
377 Jacobs Hall
Office Hours
Mondays Thursdays, 3:10 pm 4:00 pm
By appointment

Course Staff: Teaching Assistant

Yi Dong
Office hours in FGH 258:

Mondays - Thursdays: 3:15 pm - 4:30 pm


By our very own Dr. J.

Michael Fitzpatrick and
Dr. Akos Ledeczi
Available to purchase as
an iBook (Mac) or PDF

Objectives and Methodology

To introduce non-computer science students to

the analysis, design, implementation, testing,
and debugging of programs
Emphasis on using programming techniques to
solve problems

The programming language used is MATLAB

Course Management

All course information will be on Blackboard
Sign up for Piazza

You should have received an e-mail invitation

Ask questions
Answer questions
Follow specified rules (no sharing of code)

Course Elements

Good old boring lecture

Class notes (highlights), slides, and code examples
will be available on Blackboard after every class
Do not print out lecture notes on lab printers

In-class exercises
The only way to learn this is by practicing it
Use opportunity to try out what you have just
Quickly realize if you do not understand something
Ask questions

Course Elements

Homework assignments (4 total)

Individual work only
Assigned every Tuesday
Start working ASAP as the material is presented
Will help you get prepared for the exams

Two free late days

Use it to extend a deadline by 24 hours
Use carefully, they are meant for unforeseen

Course Elements
Exams (5 total)

Every Friday (except Exam 5 on Thursday)

Exam 5 is your last exam
No final exam in this course


Exam 1
Exam 2
Exam 3
Exam 4
Exam 5

Two lowest scores:
10% (each) of final grade
Three remaining scores:
15% (each) of final grade
35% of final grade

Honor Code

The Vanderbilt Honor Code governs all work in

this course
If you have questions ask your instructor or visit
the Honor Council website

Honor Code

You are not allowed to ask anyone, e.g.:

How did you do number 4?
What kind of loop did you use on number 4?
Will you look at my code for number 4 and help me
figure out what is wrong with it?

You could, however, ask something like:

I'm having trouble understanding how loops work-will you help me with that loop example we went
over in class?

When in doubt ask the instructor


Installation instructions on Blackboard

Under "MATLAB Access"

Install ASAP


Complete Assignment 0-A and 0-B

Both available on Blackboard under "Assignments
Does not require MATLAB

Assignment 1 is posted
Due Tuesday (06/09) at 1:10 pm (start of class)

Copyright 2010

Computer Science

(Photo: Paul Shaffer / UPenn)

(Photo: Oak Ridge National Laboratory)

The study of algorithms for processing

information with computers

1946: ENIAC the first electronic

general-purpose computer

2012: Titan Super computer at Oak Ridge

National Laboratory

(Photo: Oak Ridge National Laboratory)


(Photo: Paul Shaffer / UPenn)

(Photo: Oak Ridge National Laboratory)

A precise step-by-step procedure for performing a


1946: ENIAC the first electronic

general-purpose computer

2012: Titan Super computer at Oak Ridge

National Laboratory

(Photo: Oak Ridge National Laboratory)

Computers and Software

Computers can't think for themselves

They need to be told what to do very precisely

When you see a "smart" application

It is all in the software

Flashlight app


Why is programming difficult?

Algorithmic thinking is not natural to humans

We are great at things that computers still
cannot do (at least not well)
Intelligent, creative and contextual thinking


Computers are great at processing large

amounts of data fast
If you tell them what to do and how to do it via a

DARPA Robotics Challenge

A competition to develop
semi-autonomous ground
robots that can do complex
tasks in dangerous,
degraded, humanengineered environments

Still, why is it difficult?

But translating a problem to a program that

computers can "understand" requires you to
"think" like a computer
It comes naturally to some
Some others can become quite good with practice
Still some suffer to make this mental switch

The only way to get there (and become good at

it) is by doing it: practice practice practice


It is a creative process
There are a few flexible building blocks (i.e.,
programming constructs), but you decide which
ones to use, in what order, how to "configure"
them, etc.
There is an infinite number of possibilities
The same problem can be typically solved many
different ways
This makes it challenging, but really rewarding
A well-written program is just like a piece of art

Why is it important?

One of the most important classes you will take

"Everybody" writes programs these days
In engineering, science, business, and other fields
To solve all kinds of problems

"Everything" is run on software these days

e.g., cars, phones, medical devices, factories, traffic

Your programming ability may be your most

valuable asset in the job market

Simplified Computer Architecture

Von Neumann Architecture (stored program model)

Your desktop, your laptop, your phone and tablet look just like this

- Stores data and the program

- Volatile (power off erased)

- Keyboard
- Mouse
- Microphone






- Monitor
- Printer
- Speaker

- Harddisk, SSD
- Program is loaded into memory for execution
- Non-volatile

"Low-level" Programs

Executable code consists of simple instructions

that the CPU understands and executes directly
(where hardware meets the software)
The programming language that is the textual
representation of the executable code is called
assembly language
Higher level programming languages
Have more powerful instructions
Hence, they are easier to use
Programs get translated into
executable code by another program
(compiler or interpreter)
Image taken from:


Ideal for engineering and science applications

Ideal for solutions to numerical applications

Java and C++ are weak for engineering, science,

and numerical applications

Online testimonies
Go to and click on "Solutions"

Variable Names

Rules for naming variables:

Must be 63 characters in length
May contain (only) letters, numbers, and the
Must begin with a letter
Case sensitive
e.g., cat and cAt are different variables

Syntax and Semantics

x = 5

Syntax refers to the form or structure of a


"An assignment statement may be terminated with a

semicolon, a comma, a comment, or the end of line"

Semantics refers to the meaning of a command

"An assignment statement will cause the value assigned

to be printed in the Command Window, unless it is
terminated with a semicolon"