Introduction Administration Administration
Document Sample


Introduction
1
Administration
• Instructor: Dr. Michael A. Baltrush
BSEE, PhD Computer Science
• Office: GITC 4409
• Office hours: Monday 1:00-2:25PM
Thursday 1:00-1:40PM
Thursday 4:00-4:40PM
• E-mail: mab@cis.njit.edu
• Phone: 973.596.3386
2
Administration
• Text: Matlab, An Introduction with
Applications, 2nd Edition
• Lab: Mastering Matlab 7
• You must be enrolled in a lab section
Monday 2:30-3:55 Mall PC37
Wednesday 1:00-2:25 Mall PC37
3
1
Administration
• Course Grade
20% each midterm
2 March 2006, Matlab material
20 April 2006, C++ material
30% final exam, scheduled by Registrar
30% collected and graded assignments
• Exams are closed book/notes. No
calculators. No cell phones/pagers.
4
Administration
• NJIT Honor Code applies to this class.
• IF you DON’T understand – ASK!
5
Computer Program
• We all use computer programs every day
– web browsing, cell phones, cars
• A computer program is a sequence of
instructions for the computer to perform
• Instructions perform four different kinds of
operations: input, processing, output and
storage
6
2
Computer Organization
7
Input
• Program gets information from a user or
from another device
• Examples of user input devices: keyboard,
mouse, touchpad, microphone, joystick
• Examples of other devices that can be
used for input: network cable, wireless
receiver, USB port
8
Output
• Program presents information to a user or
to another device
• Examples of user output devices: display,
printer, speaker
• Examples of other devices that can be
used for output: network cable, wireless
receiver, USB port
9
3
Storage
• Save data so it can be used again and
retrieve saved data for later use
• Data usually saved in files
• Examples of permanent storage devices:
hard drive, CD, memory stick, floppy disk
10
Processing
• Arithmetic instructions: 8 + 10 = 18
• Logical instructions: Is 17 > 42?
• Instructions to get inputs
• Instructions to send outputs
• Instructions to permanently store data and
retrieve the stored data
• Instructions to temporarily store data in the
processor while the program is running
11
Hardware and Software
• A computer system consists of both
hardware and software
• Two kinds of software:
– Operating system, which interfaces with the
hardware and schedules programs to be run
– Application programs are those used directly
by the user. Examples are Word and Internet
Explorer. We will be writing application
programs
12
4
C++
• C++ is a general purpose programming
language and is an extension to a
previous programming language, C.
• C developed at Bell Labs 1969-1973 and
was used to code the Unix operating
system
• C++ developed at Bell Labs 1983-1985
• C++ added object-oriented features to C
13
Matlab
• The name Matlab is a contraction of Matrix
Laboratory
• A special purpose tool that provides
advanced mathematical functions and a
powerful plotting capability.
• Also offers programming features
14
Program Development is a
Translation Process
• Start with a problem in English
• Programmer creates an algorithm to solve
the problem. Document the algorithm
using a flowchart, pseudocode or English
• Programmer writes source code to
implement the algorithm
• Use a program (C++ compiler or Matlab)
to automatically convert the code to 1’s
and 0’s that the computer can execute
15
5
Example
• Problem: Calculate the area of any
square
16
Example
• Develop the algorithm:
– Identify the program inputs: length of a side
of the square
– Identify the program outputs: area
– Identify the calculations to be performed:
area = length * length
– Put the steps in the proper order
17
Example
• Algorithm:
Prompt the user for the length of the side
Read the length of the side from the user
Calculate: area = length * length
Display the area to the user
18
6
Comments about
Algorithms
• An algorithm is correct only if it works for
all possible inputs
• The algorithm is for your use in creating
your program – use any format you want
• It is often useful to do a desk check –
choose a couple of typical inputs, perform
the algorithm by hand, and make sure you
get the expected result
19
// This C++ program calculates the area of a square.
#include <iostream>
using namespace std;
int main()
{
float length, area;
//prompt for and read in length
cout << "Enter the length of the side of the square: ";
cin >> length;
// calculate area
area = length * length;
// display result
cout << "The area is " << area << endl;
// end
return 0;
}
20
%This Matlab script calculates the area of a square
%Prompt for and read in length
length = input('Enter the length of the side of the square: ');
%Calculate area
area = length * length;
%Display result
fprintf('The area is %f\n', area);
21
7
All Programming is
Similar
• Note that one algorithm was coded in both
C++ and Matlab – algorithms are
independent of the programming language
• Note that the two programs are similar but
not identical. For example, C++ uses // for
comments and Matlab uses %
22
A Source Code Listing has
Two Users
• The first user is the C++ compiler or
Matlab – it will translate everything that is
not a comment to 1’s and 0’s. This text
must be PERFECT – absolutely no typos
• The second user is a human who wants to
understand the code, who will mostly use
the comments. Typos in comments are
OK.
23
8
Related docs
Get documents about "