cs 108 computing fundamentals january 22, 2015. ghp #1 looks like i’m missing just a couple...
TRANSCRIPT
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 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
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
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)
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
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
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
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
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
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
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
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
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
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/
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
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
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
/ (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
/ (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
/ (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
/ (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
/ (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
/ (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
/ (root) (7)|
--------------------------------------------------------------------------------------
| | | | | |
/bin /dev /etc /home /usr /lib
|
------------------------------------
| |
/f /s
|
---------------------------
|
/csci
|
---------------------------
|
/urbanc
• pwd• My entire path is: /home/f/csci/urbanc
/ (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
/ (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
/ (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
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
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
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
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?
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
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!!
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?
Let's Develop Some Algorithms
• Take 5 minutes and write down an algorithm for "sharpening a pencil"
Pseudocode
• Pseudocode:http://www.minich.com/education/wyo/stylesheets/pseudocode.htm
http://www.wiley.com/college/busin/icmis/oakman/outline/chap05/slides/pseudo.htm
http://www.unf.edu/~broggio/cop2221/2221pseu.htm
http://userpages.wittenberg.edu/bshelburne/Comp150/Algorithms.htm
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
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
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.
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.
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
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?
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
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
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
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
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
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
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/
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
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