1 / 50

CS 108 Computing Fundamentals August 28, 2014

CS 108 Computing Fundamentals August 28, 2014. GHP #1. Looks like I’m missing just a couple submissions If you need help, please see me ASAP I will have graded many submissions already You will receive/have received a reply message from me with a grade

italia
Download Presentation

CS 108 Computing Fundamentals August 28, 2014

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 108 Computing Fundamentals August 28, 2014

  2. GHP #1 • Looks like I’m missing just a couple submissions • If you need help, please see me ASAP • I will have graded many submissions already • You will receive/have received a reply message from me with a grade • The reply message will go to Fang… you’ll need to use Alpine to read it

  3. GHP #2 • Due on Tuesday • We will discuss as part of class today • The rubric that I will use for grading is posted • Please don’t submit anything for GHP #2 until you review the rubric

  4. 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

  5. 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 hardware • Programs interact with other programs through the OS

  6. 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... SSH is not an interface... SSH is a connectivity tool • UNIX uses "shells" as interfaces

  7. 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

  8. 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

  9. 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

  10. 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

  11. 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

  12. 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 pages • man ls • Hit spacebar to move forward and q to quit

  13. 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/

  14. 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

  15. 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

  16. 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

  17. / (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

  18. / (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

  19. /(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

  20. / (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

  21. / (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

  22. / (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

  23. / (root) (7) | -------------------------------------------------------------------------------------- | | | | | | /bin /dev /etc /home /usr /lib | ------------------------------------ | | /f /s | --------------------------- | /csci | --------------------------- | /urbanc • pwd • My entire path is: • /home/f/csci/urbanc

  24. / (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

  25. / (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

  26. / (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

  27. 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

  28. 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 nano

  29. How Do We Create Text Files • We'll start editing with nano • From your Fang prompt enter • nano file-identifier • note: file identifiers usually have two parts • file name .file type • such as • stuff.txt or ghp1.c • Additional slides/material on nano: • https://www.cs.sunyit.edu/~urbanc/cs_108_aug_28a.html

  30. 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?

  31. 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

  32. Problem Solving Acording toGeorge Polya • Understand the problem (and the audience) • Are you building a chair? • Need directions to a location? • Making popcorn? • Trying to solve a puzzle? • Devise a plan • Is this similar to something else? • Who is the audience for the solution? • What are the required steps (need gruesome detail)?

  33. Problem Solving According to George Polya • Carry out the plan (implement) • Does it work? • Is each step correct? Necessary? • Is the solution accurate? (Correct?) • Will it always lead to a solution?

  34. Let's Develop Some Algorithms • Take 5 minutes and write down an algorithm for "sharpening a pencil"

  35. 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

  36. Homework: GHP #1b (1 of 2) Note 1 - for Section 01 students: due no later than 2 PM on Tuesday, September 2, 2014Note 2 - for Section 35W students: due no later than 11:59 PM on Tuesday, September 2, 2014 Task #1: Complete the Unix Tutorial found at the following Web site: http://unix-tutorial.cs.sunyit.edu/evaluation/ 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

  37. Homework: GHP #1b (2 of 2) Task #2: Send me an Alpine e-mail message using FANG and tell me what you think of the UNIX tutorial (a paragraph will be appropriate).  The "Subject" line of your e-mail message to me shall be in EXACTLY the following format: Subject:  CS 108 / GHP #1b / Complete or Need Help (pick the appropriate one) GHP #1b Assessment Rubric

  38. Homework: GHP #2 • Note 1 - for Section 01 students: due no later than 2 PM on Tuesday, September, 2014Note 2 - for Section 35W students: due no later than 11:59 PM on Tuesday, September 2, 2014 • Using your DogNet account and the nano 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. 

  39. 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.

  40. Homework: GHP #2 Continued • The subject line of any/all GHP-related e-mail shall contain three pieces of info: • The course number (CS 108) • The letters "GHP" and the appropriate number • The word "Complete" or the phrase "Need Help" • Examples: • Subject: CS 108 / GHP #2 / Complete • or • Subject: CS 108 / GHP #2 / Need Help

  41. 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?

  42. What Can a Computer Do? A computer can receive or accept data (input) A computer can store data in a memory device A computer can perform arithmetic operations/instruction and data manipulation operations/instructions A computer can select one of some number of alternatives based upon some decision criteria A computer can repeat a group of operations/instructions A computer can output information

  43. 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

  44. Steps Are The Steps In Developing a Program? • Determine the desired output(s) • Determine the necessary input(s) • Develop an algorithm • Select the ordered, atomic steps necessary to transform the necessary input(s) into the desired outputs • Check the algorithm by hand for correctness • Use the algorithm to guide development of source-code using a programming language (we will use C) • Test and troubleshoot every algorithmic step • Document (comment) as source-code is being developed • Test and troubleshoot the entire program

  45. Elements of a C Program (1 of 5)(notice there are many different Web sites) • Character Set • http://aboutc.weebly.com/c-character-set.html • Tokens (not an all inclusive list… but pretty inclusive) • Keywords • http://aboutc.weebly.com/keywords.html • Identifiers • http://aboutc.weebly.com/identifiers.html

  46. Elements of a C Program (2 of 5) • Constants • http://aboutc.weebly.com/definition-and-its-types.html • Integer Constants • http://aboutc.weebly.com/integer-constants.html • Real Constants • http://aboutc.weebly.com/real-constants.html • Character Constants • http://aboutc.weebly.com/character-constants.html • String Constants • http://aboutc.weebly.com/string-constants.html

  47. Elements of a C Program (3 of 5) • Operators (not all inclusive) • http://aboutc.weebly.com/definition-and-its-types1.html • Arithmetic • http://aboutc.weebly.com/arithmetic.html • Relational • http://www.tutorialspoint.com/cprogramming/c_relational_operators.htm • Logical • http://www.tutorialspoint.com/cprogramming/c_logical_operators.htm

  48. 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/

  49. 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 • Variables • http://www.zentut.com/c-tutorial/c-variables/ • Expressions and 6. Statements • http://farside.ph.utexas.edu/teaching/329/lectures/node11.html

  50. Let’s Stop Here • Study the links of the previous 5 slides… know them well!! • The Web is full of helpful sites!!! • Do GHP #1b and GHP #2 • Read Chapter 2 • Play with UNIX!! • See you on Tuesday

More Related