ECE Application Programming

Download Report

Transcript ECE Application Programming

16.216
ECE Application Programming
Instructor: Dr. Michael Geiger
Spring 2015
Lecture 1:
Course overview
Basic C program structure
Lecture outline

Announcements/notes

Program 1 due Monday, 1/26



40 points: complete simple C program
10 points: introduce yourself (preferably at my office)
Today’s lecture

Course overview






Introduction to C programming


7/17/2015
Instructor information
Course materials
Course policies
Resources
Course outline
Program development cycle
Basic program structure
ECE Application Programming: Lecture 1
2
Course staff & meeting times

Lectures:


MWF 8-8:50, Ball 314
Instructor: Dr. Michael Geiger




E-mail: [email protected]
Phone: 978-934-3618 (x43618 on campus)
Office: 118A Perry Hall
Office hours: M 10-11:30, W 10-11:30, Th 5-6



7/17/2015
Student questions are top priority during these hours
Also available by appointment at other times
May not be available regularly at start of term, but I plan
to be on campus more as semester goes on. Will
announce additional times as they become available.
ECE Application Programming: Lecture 1
3
Course materials

Textbook: K.N. King, C Programming: A
Modern Approach, 2nd edition, 2008, W.W.
Norton.


ISBN: 978-0-393-97950-3
Course tools: Need integrated development
environment (IDE) that compiles/runs C code

Recommended IDEs (all free; links on web)



7/17/2015
Windows: Microsoft Visual Studio Express (MS website)
Mac: Xcode (Mac App Store)
Linux: gcc/gdb (text-based; can run through terminal on
Mac as well)
ECE Application Programming: Lecture 1
4
Additional course materials

Course websites:
http://mgeiger.eng.uml.edu/16216/sp15/index.htm
http://mgeiger.eng.uml.edu/16216/sp15/schedule.htm


Will contain lecture slides, handouts, assignments
Discussion group through piazza.com:



7/17/2015
Allow common questions to be answered for
everyone
All course announcements will be posted here
Will use as class mailing list—please enroll ASAP
ECE Application Programming: Lecture 1
5
Course policies


Prerequisite: 25.107 (Intro to Engineering), ECE
major
Academic honesty



All assignments are to be done individually unless
explicitly specified otherwise by the instructor
Any copied solutions, whether from another student or
an outside source, are subject to penalty
You may discuss general topics or help one another
with specific errors, but do not share assignment
solutions

7/17/2015
Must acknowledge assistance from classmate in submission
ECE Application Programming: Lecture 1
6
Programming assignments

Will submit all code via e-mail to Dr. Geiger


Penalty after due date: -(2n-1) points per day



Will not get confirmation unless you explicitly ask
i.e., -1 after 1 day, -2 after 2 days, -4 after 3 days …
Assignments that are 8+ days late receive 0
See grading policies (last three pages of today’s
handout) for more details on:




7/17/2015
Grading rubric
Common deductions
Regrade policy
Example grading
ECE Application Programming: Lecture 1
7
Programming assignments: regrades





You are allowed one penalty-free resubmission per
assignment
Each regrade after the first: 1 day late penalty
Must resubmit by regrade deadline, or late
penalties will apply
Late penalty still applies if original submission late
“Original submission”  first file submitted
containing significant amount of relevant code

In other words, don’t turn in a virtually empty file just
to avoid late penalties—it won’t count
7/17/2015
ECE Application Programming: Lecture 1
8
Grading and exam dates

Grading breakdown





Programming assignments: 60%
Exam 1: 10%
Exam 2: 15%
Exam 3: 15%
Exam dates



7/17/2015
Exam 1: Wednesday, February 18 in class
Exam 2: Wednesday, April 1 in class
Exam 3: TBD (during finals)
ECE Application Programming: Lecture 1
9
Tentative course outline










Basic C program structure and development
Working with data: data types, variables,
operators, expressions
Basic console input/output
Control flow
Functions: basic modular programming,
argument passing
Pointers, arrays, and strings
File & general input/output
Bitwise operators
Creating new data types: structures
Dynamic memory allocation
7/17/2015
ECE Application Programming: Lecture 1
10
Programming exercises

Note on course schedule: several days
marked as “PE#”

Those classes will contain supervised, in-class
programming exercises



7/17/2015
We’ll write/complete short programs to illustrate
previously covered concepts
If you have a laptop, bring it
May have to do some design ahead of time ...
ECE Application Programming: Lecture 1
11
Course questions
General notes/questions about the course:
1. How many of you have prior programming
experience?
For those that do, can improve programming
style, efficiency, potentially learn new items
For those that don’t, course assumes no prior
programming experience
Fair warning for all of you: material builds on
itself throughout course





7/17/2015
Difficulty increases as course goes on
If (when) you get stuck, ask for help!!!
ECE Application Programming: Lecture 1
12
Course questions (continued)
How many of you are taking this course only
because it’s required?
2.


Follow-up: how many of you hope you’ll never
have to program again once you’re done with the
course?
Both computer and electrical engineers commonly
program in industry—some examples:




7/17/2015
Automation of tasks
Circuit simulation
Test procedures
Programming skills highly sought by employers
ECE Application Programming: Lecture 1
13
Program development


... which is a good approach for your
assignments, too!
Average student’s approach to programming

Read specification (assignment)




Attempt to write complete program
Find output error and fix related code
Repeat previous step until either


7/17/2015
... at least some of it, anyway ...
Code completely works ...
... or code is such a mess that problem(s) can’t be fixed
ECE Application Programming: Lecture 1
14
Program development (cont.)

A more structured approach to program
development


Read specification
Identify requirements



Plan design that implements requirements




7/17/2015
What results should program produce?
How can I test correctness of those results?
Using flowchart, pseudocode, etc.
Plan for tests as well
Translate design into actual code
Test program and fix errors
ECE Application Programming: Lecture 1
15
Our first C program
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
16
Our first C program
# indicates pre-processor directive
include is the directive
stdio.h is the name of the file to "insert" into
our program. The <> means it is part of the C
development system
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
17
Our first C program
main is the name of the primary (or main) procedure. All
ANSI C programs must have a main routine named main
The () indicates that main is the name of a procedure.
All procedure references must be followed with ()
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
18
Our first C program
{ } enclose a "block". A block is zero or more C statements.
Note that code inside a block is typically indented for
readability—knowing what code is inside the current block is
quite useful.
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
19
Our first C program
printf() is a "built-in" function (which is actually defined in
stdio.h).
"Hello World!" is the string to
print.
More formally, this is called the
control string or control specifier.
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
Every statement must end with a ";". Preprocessing
directives do not end with a ";" (but must end with a return).
7/17/2015
ECE Application Programming: Lecture 1
20
Our first C program
The \n is an escape character used by the printf
function; inserting this character in the control string causes
a “newline” to be printed—it’s as if you hit the “Enter” key
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
21
Our first C program
The int tells the compiler our main() program will return
an integer to the operating system; the return tells what
integer value to return. This keyword could be void,
indicating that the program returns nothing to the OS.
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
7/17/2015
ECE Application Programming: Lecture 1
22
Final notes

Next time:

Data in C




Data types
Constants
Variables
Reminders:


Sign up for the course discussion group on
Piazza!
Program 1 due Monday, 1/26


7/17/2015
40 points: complete simple C program
10 points: introduce yourself (preferably at my office)
ECE Application Programming: Lecture 1
23