cs 108 computing fundamentals january 22, 2015. ghp #1 looks like i’m missing just a couple...

51
CS 108 Computing Fundamentals January 22, 2015

Upload: rosamund-french

Post on 04-Jan-2016

218 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

CS 108 Computing Fundamentals

January 22, 2015

Page 2: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

GHP #1

• Looks like I’m missing just a couple submissions If you need help, please see me ASAP

• I have not yet graded your submissions You will receive/have received a reply message from me with a

grade… probably today sometime The reply message will go to Fang… you’ll need to use Alpine

to read it

Page 3: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

GHP #1b and #2

• Due on Tuesday

• We will discuss as part of class today

• The rubrics that I will use for grading are posted Please don’t submit anything for GHP #1b or #2 until you

review the rubrics

Page 4: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Class Videos

https://classx.cs.sunyit.edu/

•Login

•Click on "Semesters"

•Click on "SPRING 2015 Semester"

•Click on "CS 108 01: Computing Fundamentals (Spring 2015)

Page 5: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Operating Systems (1)

• Software that manages the hardware and software resources of a computer.

• Performs basic tasks

– controls and allocates memory

– prioritizes the processing of instructions

– controls input and output devices

– facilitates networking

– manages files

– and more

Page 6: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Operating Systems (2)

• Main advantages of an OS:

– Multiple programs can run concurrently

– Multiple people can use hardware/software concurrently

– Simplifies the programming of application software program do not have to manage hardware directly

programs work through the OS to interact with hardwarePrograms interact with other programs through the OS

Page 7: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Operating Systems (3)

• Lowest level of any operating system is its kernel – first layer of software loaded into memory when a system boots– provides access to various common core services – Scott Spetka offers a LINUX kernel programming course

• Most computer users:– use Microsoft Windows as their OS of "choice"– Windows uses a GUI to "interact" with the OS

The interface and the OS are different animals• We are going to use the UNIX every time we login to Fang on

DogNet... Putty is not an interface... Putty is a connectivity tool – UNIX uses "shells" as interfaces

Page 8: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

UNIX Shells

• There are a number of shells available

• DogNet uses the tcsh shell

• We can prove that by having DogNet tell us the shell that we're using

– At the fang prompt enter this command:

echo $SHELL

• Note: You do not have the authority to change shells

Page 9: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can We Do With UNIX (1)

• What can we do with UNIX? – The sky is the limit!! – UNIX is the backbone of the Internet– Here’s another great tutorial

http://people.ischool.berkeley.edu/~kevin/unix-tutorial/toc.html

Page 10: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can We Do With UNIX (2)

• Let's start small... let's make sure you are who you think you are:– At the Fang prompt enter:

whoami

• Let's find out who is logged onto the system right now– At the Fang prompt enter:

who• Let's compare the results of who with the results of w

– At the Fang prompt enter: w

Page 11: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can We Do With UNIX (3)

• What about things that you normally "point and click" to accomplish in Windows?

– You don't need Windows to get things done even when you're using Windows

– Windows has a DOS prompt available

– DOS and UNIX commands are pretty similar

– Check the next slide

Page 12: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can We Do With UNIX (4)

Command UNIX DOS/Windows

List directory content ls dir

Copy a file cp copy

Delete a file rm del

Rename a file mv rename

Display contents cat type

Print a file lpr print

Change directory cd cd

http://yolinux.com/TUTORIALS/unix_for_dos_users.html

Page 13: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can We Do With UNIX (5)

Command UNIX DOS/Windows List directory content ls dir List directories with a / ls –F

or ls –p

• How can we learn more about the ls command from within the UNIX shell?– man pages

Manual pagesman ls

Hit spacebar to move forward and q to quit

Page 14: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

UNIX Help is Everywhere

• Tiny sample of help available

– http://www.rain.org/~mkummel/unix.html

– http://www.computerhope.com/unix.htm

– http://unixhelp.ed.ac.uk/

– http://bignosebird.com/unix.shtml

– http://www.ee.surrey.ac.uk/Teaching/Unix/

Page 15: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let's Talk About Directories (1)

• What is a directory?

– a place to store files (a virtual of a container for files… think of something similar to Windows “folders” )

– ls alone shows you files in your current working directory, but there are other directories

– directories can contain files and/or other directories

Page 16: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let's Talk About Directories (2)

– Directories in a UNIX file system are organized into a hierarchy, starting at the root directory

– When you refer to a file in a command, that file is assumed to be in the current directory

– You can refer to a file in some other directory by using or including its pathname

• You can use the pwd command to find out where you are located in the directory structure… pwd tells me, right at this moment, my present working directory is:

/home/f/csci/urbanc

Page 17: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let's Talk About Directories (3)

• You can use the pwd command to find out where you are located in the directory structure… pwd tells me, right at this moment, my present working directory is:

/home/f/csci/urbanc

• The left-most / represents the root directory… the other / are separators between directories in the directory hierarchy… we can use /home/f/csci/urbanc to determine the information on the next slide

Page 18: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (1)|

--------------------------------------------------------------------------------------

|

/home

|

------------------------------------

|

/f

|

---------------------------

|

/csci

|

---------------------------

|

/urbanc

/home/f/csci/urbanc•Tells me that my (urbanc’s) home directory is 4 levels down from the root•At this point I have no idea what other directories and files are in the hierarchy•Let’s explore

Page 19: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (2)|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /boot /home /usr /lib

• pwd• cd / (change directory to the root)• ls • ls -p • We now see directories other than

home that are directly under root

Page 20: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (3)

|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /etc /home /usr /lib

|

----------------------------------------------------------------------

| | | |

/staff /f /u /s

• pwd• cd home (change to home sub-

directory of root )• ls • ls -p • We now see directories other than f

that are directly under or subdirectories of home

Page 21: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (4)|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /etc /home /usr /lib

|

------------------------------------

| |

/f /s

|

---------------------------

| | |

/csci /mgmt /tele

• pwd• cd f (change to f sub-directory of

home)• ls • ls -p• We now see directories other

than csci that are directly under or subdirectories of f

Page 22: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (5)|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /etc /home /usr /lib

|

------------------------------------

| |

/f /s

|

---------------------------

|

/csci

|

---------------------------

| |

/urbanc /ron

• pwd• cd csci (change to csci sub-directory

of f )• ls • ls -p • We now see directories other than

urbanc that are directly under or subdirectories of csci

Page 23: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (6)|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /etc /home /usr /lib

|

------------------------------------

| |

/f /s

|

---------------------------

|

/csci

|

---------------------------

|

/urbanc

• pwd• cd urbanc (change to urbanc sub-

directory of csci )• ls • ls -p • Now you see all the files and

directories in my home directory

Page 24: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (7)|

--------------------------------------------------------------------------------------

| | | | | |

/bin /dev /etc /home /usr /lib

|

------------------------------------

| |

/f /s

|

---------------------------

|

/csci

|

---------------------------

|

/urbanc

• pwd• My entire path is: /home/f/csci/urbanc

Page 25: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (8)|

--------------------------------------------------------------------------------------| | | | | |

/bin /dev /etc /home /lib /usr | |

------------------------------------ --------- | | |

/f /s /games | --------------------------- | /csci

| ---------------------------

| /urbanc

• fortune is a program in the games directory

• From my directory (or any directory that is lateral or below the directory where your the intended file resides) one needs to use the entire path to "run" fortune

/usr/games/fortune

Page 26: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (9)|

--------------------------------------------------------------------------------------| | | | | |

/bin /dev /etc /home /lib /usr | |

------------------------------------ --------- | | |

/f /s /games | --------------------------- | /csci

| ---------------------------

| /urbanc

• fortune is a program in the games directory

• From the usr directory (or any directory that is in the path and above the directory where your the intended file resides) I may use the relative path to "run" fortune

games/fortune

Page 27: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

/ (root) (10)|

--------------------------------------------------------------------------------------| | | | | |

/bin /dev /etc /home /lib /usr | |

-------------------------------------------- | | |

/undergrad /s /f | --------------------------- | / (username)

• Student directories reside in the path /home/undergrad • cd /home/undergrad• ls - p• The OS protects users against intruders

Page 28: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

If You Get Lost in The UNIX File System

• No matter where you are, at the command prompt type cd then hit the enter key: this takes you back to your home directory

Page 29: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

How Do We Create Text Files

• As you might guess, we need to use a text editor

• Windows/DOS provides Notepad as a very simple text editor

• UNIX provides nano (pronounced nan-o) and pico (pronounced peek-oh) and vi ( pronounced vee-eye)

• We'll start editing with pico

Page 30: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

How Do We Create Text Files

• We'll start editing with pico

• From your Fang prompt enter

pico file-identifier

– note: file identifiers usually have two parts

file name . file type

such as

stuff.txt or ghp1.c

• Additional slides/material on pico:

https://www.cs.sunyit.edu/~urbanc/cs_108_jan_22a.html

Page 31: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

New Topic: Let's Talk About Algorithms

• An algorithm is an ordered set of unambiguous, atomic, executable steps, defining a terminating process.

– [1] an ordered set?

– [2] unambiguous?

– [3] atomic?

– [4] executable steps?

– [5] defining a terminating process?

Page 32: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Why Are Algorithms Important?

• Easier to understand what is to be accomplished

• Easier to find errors and fix them

• Algorithms are independent of H/W and S/W

• Algorithms guide our "program development" because they act as a detailed guide or blueprint or GPS guided roadmap

http://userpages.wittenberg.edu/bshelburne/Comp150/Algorithms.htm

Page 33: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Problem Solving Acording toGeorge Polya

1. Understand the problem (and the audience)

• Are you building a chair?

• Need directions to a location?

• Making popcorn?

• Trying to solve a puzzle?

2. Devise a plan

• Is this similar to something else?

• Who is the audience for the solution?

• What are the required steps? Need gruesome detail!!

Page 34: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Problem Solving According to George Polya

3. Carry out the plan (implement)

• Does it work?

• Is each step correct? Necessary?

4. Is the solution accurate? (Correct?)

• Will it always lead to a solution?

Page 35: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let's Develop Some Algorithms

• Take 5 minutes and write down an algorithm for "sharpening a pencil"

Page 37: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Homework: GHP #1b (1 of 2)

Note 1 - due no later than 8 AM on Tuesday, January 27, 2015

Task #1: Complete all the "Lessons" and all the "Execises" at the following Web site:

http://unix-tutorial.cs.sunyit.edu

Be Aware #1: help is available via "man pages"... at the FANG prompt type "man " (without the double quotation marks) followed by a space followed by the UNIX command of interest... an example would be: man pwd

Be Aware #2: A search engine and the Internet can be your very useful

Page 38: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Homework: GHP #1b (2 of 2)

Task #2: Send me an Alpine e-mail message using FANG andtell me what you think of the UNIX tutorial (a paragraphwill be appropriate).  The "Subject" line of your e-mail

message to meshall be in EXACTLY the following format:

Subject:  CS 108 / GHP #1b / Complete or Need Help (pick the appropriate one)

GHP #1b Assessment Rubric     

Page 39: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Homework: GHP #2

Note 1 - due no later than 8 AM on Tuesday, January 27, 2015

Using your DogNet account and the pico editor, create a file that contains three algorithms that could be used as the "blueprint" to accomplish three different tasks.  I suggest you use "structured English" or "pseudocode" or "bulletized English phrases" as a means to communicate your algorithms. When you have successfully completed your three algorithms, send me the single file that contains the three algorithms as an attachment (see next slide) to an ALPINE mail message. 

Page 40: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Homework: GHP #2 continued

• To attach a file, just type the name of the file in the "Attchmnt:" field. 

• Another way to attach a file:  position your cursor (use the arrow keys and not the

mouse) in the "ATTCHMNT" field an then hit type CTRL-T (^T).   You can use the spacebar to move down and then hit

"ENTER" when the correct file is highlighted, or you can hit L to enter the "LIST MODE" and then the letter "X" to mark each the files you want to attach, followed by the letter S to select those marked files as attachments.

Page 41: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Homework: GHP #2 Continued

• The subject line of any/all GHP-related e-mail shall contain three pieces of info:

1. The course number (CS 108)2. The letters "GHP" and the appropriate number3. The word "Complete" or the phrase "Need Help"

• Examples:Subject: CS 108 / GHP #2 / Complete

or Subject: CS 108 / GHP #2 / Need Help

Page 42: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let’s Start Talking About Programming

1. What can a computer do?

2. What is programming?

3. What are the steps to develop a program?

4. What are the elements of a C program?

Page 43: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What Can a Computer Do?

1. A computer can receive or accept data (input)

2. A computer can store data in a memory device

3. A computer can perform arithmetic operations/instruction and data manipulation operations/instructions

4. A computer can select one of some number of alternatives based upon some decision criteria

5. A computer can repeat a group of operations/instructions

6. A computer can output information

Page 44: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

What is Programming?

• A program is a very specific set of instructions that making a computer do what you want it to do

• Programming is the process of creating a program Developing a solution Setting up of a related series of instructions which will

produce the desired results/outcomes/outputs

Page 45: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Steps Are The Steps In Developing a Program?

1. Determine the desired output(s)

2. Determine the necessary input(s)

3. Develop an algorithm

A. Select the ordered, atomic steps necessary to transform the necessary input(s) into the desired outputs

B. Check the algorithm by hand for correctness

4. Use the algorithm to guide development of source-code using a programming language (we will use C)

A. Test and troubleshoot every algorithmic step

B. Document (comment) as source-code is being developed

5. Test and troubleshoot the entire program

Page 46: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Elements of a C Program (1 of 5)(notice there are many different Web sites)

1. Character Set

http://aboutc.weebly.com/c-character-set.html

2. Tokens (not an all inclusive list… but pretty inclusive)

•Keywords

http://aboutc.weebly.com/keywords.html

•Identifiers

http://aboutc.weebly.com/identifiers.html

Page 47: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Elements of a C Program (2 of 5)

• Constants

http://aboutc.weebly.com/definition-and-its-types.htmlInteger Constants

http://aboutc.weebly.com/integer-constants.htmlReal Constants

http://aboutc.weebly.com/real-constants.htmlCharacter Constants

http://aboutc.weebly.com/character-constants.htmlString Constants

http://aboutc.weebly.com/string-constants.html

Page 48: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Elements of a C Program (3 of 5)

• Operators (not all inclusive)

http://aboutc.weebly.com/definition-and-its-types1.htmlArithmetic

http://aboutc.weebly.com/arithmetic.htmlRelational

http://www.tutorialspoint.com/cprogramming/c_relational_operators.htmLogical

http://www.tutorialspoint.com/cprogramming/c_logical_operators.htm

Page 49: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Elements of a C Program (4 of 5)

Increment

http://www.c4learn.com/c-programming/c-increment-operator/

Decrement

http://www.c4learn.com/c-programming/c-increment-operator/

Assignment

http://www.c4learn.com/c-programming/c-assignment-operator/

Comma

http://www.c4learn.com/c-programming/c-comma-operator/

Page 50: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Elements of a C Program (5 of 5)

3. Data Types

http://www.lix.polytechnique.fr/~liberti/public/computing/prog/c/C/CONCEPT/data_types.html#intDecrement

4.Variables

http://www.zentut.com/c-tutorial/c-variables/

5.Expressions and 6. Statements

http://farside.ph.utexas.edu/teaching/329/lectures/node11.html

Page 51: CS 108 Computing Fundamentals January 22, 2015. GHP #1 Looks like I’m missing just a couple submissions  If you need help, please see me ASAP I have

Let’s Stop Here• Study the links of the previous 5 slides… know them well!!

The Web is full of helpful sites!!! Go to "CS 108 Links" page for more!!

http://web.cs.sunyit.edu/~urbanc/cs_108_links.html

• Do GHP #1b and GHP #2

• Read/study Chapter 2

• Play with UNIX!!

• See you on Tuesday