9-5-2018 Chapter 1 Notes PDF

Title 9-5-2018 Chapter 1 Notes
Author Stephen Phillips
Course Computer Science I
Institution University of Nevada, Las Vegas
Pages 3
File Size 141.5 KB
File Type PDF
Total Downloads 50
Total Views 135

Summary

Dr. Juyeon Jo - These are the notes that correspond with the chapter in Computer Science 135....


Description

CS 135 Lab Hardware/Software Programming in C++ -

-

-

-

Naming files o A C++ program file name must end in .cpp o Generally speaking, only use letters, digits, underscores, dashes, and periods in file names (start with a letter) Emacs – editor to create program files o Command to save file: Ctrl-X Ctrl-S o Command to exit emacs: Ctrl-X Ctrl-C o Best way to start emacs = emacs filename o Filename~ is a backup file automatically created by emacs IMPORTANT! – when connecting remotely (SSH) o Backspace key does not work – Delete sends a backspace o See instructions in CS 135 Lab Manual to set Backspace key Compile the program by typing at the command-line: g++ Hello.cpp Compiler checks that the program obeys the language rules Compiler translates into machine language (object program) If compilation is successful, executable file will be created named a.out (called the object file) Execute it by typing at the command-line: ./a.out Review results to determine if program achieves desired goal If compilation is not successful, error messages will be displayed to the screen o Read error messages, noting line numbers cited o Go back to editor and modify code appropriately o Try recompiling

Some Basic Linux Commands -

-

-

ls – the list command displays an alphabetical list of all the files and directories in your current directory cat – the concatenate command allows a user to display the entire context of a text file to screen o Example: cat afile more – the more command allows the user to display the content of a file one screen (or page) at a time (similar to cat command) – press space bar to display the next page, q to quit o Example: more bfile lpr – the line print command is used to send a file to a printer (in TBE B361 sends to Ponderosa by default) cp – the copy command is used to copy the content of one file to another file – in the example below bfile is created and will have the same content as afile o Example: cp afile bfile man – the man command provides the user with access to an online manual for Linux commands o Example: man ls

The Process

Chapter 2 Computer program -

Sequence of statements whose objective is to accomplish a task

Programming -

Process of planning and creating a program

Programming Language -

A set of rules, symbols, and special words

C++ is case sensitive – upper case and lower case letters are different Basic Elements of C++ All programming languages have 2 aspects -

-

Syntax: grammar rules of the language o Describes the rules for how legal statements will be written o Program will not compile if these rules are violated o Compiler will try to identify and locate syntax errors Semantics: meaning of the instructions in the language o Compiler cannot find these errors – often called logic errors

C++ program is a collection of one or more functions -

A function is a collection of statements designed to perform a task Every C++ program requires a function called main Execution of the program will begin and usually end in main Some functions are predefined or standard and are provided as part of the system

A C++ Program -

-

Compilation/execution o G++ is the C++ compiler o Compile command: g++ progfile.cpp o Run command: ./a.out progfile.cpp is the human readable version of the program; referred to as the source file a.out is the machine-readable version of the program; referred to as the object file – only generated if compilation was successful...


Similar Free PDFs