CPS120: Introduction to Computer Science Compiling Your First Program.

Slides:



Advertisements
Similar presentations
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Advertisements

CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Introduction to the gedit editor. gedit: the Gnome editor Gnome: Gnome is a freely available (i.e., no cost) desktop environment for the UNIX system The.
Microsoft Word 2003 Tutorial 2 – Editing and Formatting a Document.
Introduction to Windows File Management
Access - Project 1 l What Is a Database? –A Collection of Data –Organized in a manner to allow: »Access »Retrieval »Use of That Data.
The Windows Registry Adapted from
1 Lab Session-I CSIT120 Spring2001 Using Windows Using An Editor Using Visual C++ Using Compiler Writing and Running Programs Lab-1 continues (Session.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Here’s how to start the Microsoft Visual C++ program; click on start, then programsclick on start, then programs Choose Microsoft Visual C++ or Microsoft.
Key Applications Module Lesson 12 — Word Essentials
Fundamentals of Programming in Visual Basic 3.1 Visual basic Objects Visual Basic programs display a Windows style screen (called a form) with boxes into.
Conversational Computers
LSU 06/04/2007BASIC Stamp Editor1 The BASIC Stamp Editor Programming Unit, Lecture 3.
Chapter 2 Software Tools and Assembly Language Syntax.
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
A First Program Using C#
Internet Skills An Introduction to HTML Alan Noble Room 504 Tel: (44562 internal)
Introduction to VB.NET Tonga Institute of Higher Education.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
MICROSOFT WORD GETTING STARTED WITH WORD. CONTENTS 1.STARTING THE PROGRAMSTARTING THE PROGRAM 2.BASIC TEXT EDITINGBASIC TEXT EDITING 3.SAVING A DOCUMENTSAVING.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
1 2 Lab 2: Organizing Your Work. 2 Competencies 3 After completing this lab, you will know how to: 1. Use Explorer to manage files. 2. Copy files. 3.
Chapter Three The UNIX Editors. 2 Lesson A The vi Editor.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
File Management Presented to The Glades Computer Club January 4, 2001.
CPS120: Introduction to Computer Science Compiling Your Programs Using Visual C++
Just as there are many human languages, there are many computer programming languages that can be used to develop software. Some are named after people,
CPSC1301 Computer Science 1 Overview of Dr. Java.
Program Design and Coding
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
Tutorial 11 Five windows included in the Visual Basic Startup Screen Main Form Toolbox Project Explorer (Project) Properties.
Getting Started with MATLAB 1. Fundamentals of MATLAB 2. Different Windows of MATLAB 1.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java.
XP New Perspectives on Windows 2000 Professional Windows 2000 Tutorial 2 1 Microsoft Windows 2000 Professional Tutorial 2 – Working With Files.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft® Excel 2013.
Getting Started with Word & Saving Guided Lesson.
CPS120: Introduction to Computer Science Introduction to C++
CPS120: Introduction to Computer Science Compiling Your First Program.
Introduction to Word Processing.  Learn uses of word-processing software  Differentiate between typewriter and word- processing software  Explore various.
© I-Logix Rhapsody C++ V /01/2004E1-1 “Essential” Tool Training Basic Rhapsody Basic Rhapsody Rhapsody in C++ V /01/04.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
XP New Perspectives on Microsoft Windows XP Tutorial 2 1 Microsoft Windows XP Working with Files Tutorial 2.
Access Module Implementing a Database with Microsoft Access A Great Module on Your CD.
11 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
Visual Basic.Net. Software to Install Visual Studio 2005 Professional Edition (Requires Windows XP Pro) MSDN Library for Visual Studio 2005 Available.
Microsoft Office 2007: Introductory Pasewark & Pasewark 1.
Word and the Writing Process. To create a document 1.On the Start menu, point to Programs, and then click Microsoft Word. A new document opens in Normal.
The Debugging Process Syntax Errors CPS120 Introduction to Computer Science Lecture 4.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Key Applications Module Lesson 12 — Word Essentials Computer Literacy BASICS.
Software Development Languages and Environments. Computer Languages Just as there are many human languages, there are many computer programming languages.
Welcome to the Basic Microsoft Word Guide. Before you start this Guide, you will need to complete “Basic Computer”; “Basic Windows” and know how to type.
PROBLEM SOLVING WARM-UP Fill in the spaces using any operation to solve the following (!, (), -/+,÷,×): = 6.
Fundamentals of Windows Mouse n 4 Basic Operations: –Pointing –Clicking –Double Clicking –Dragging.
Excel Tutorial 8 Developing an Excel Application
Word Lesson 1 Word Basics
CSC201: Computer Programming
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Key Applications Module Lesson 12 — Word Essentials
Introduction to TouchDevelop
An Introduction to Debugging
Running a Java Program using Blue Jay.
Key Applications Module Lesson 12 — Word Essentials
Chapter 1 Introducing Small Basic
Presentation transcript:

CPS120: Introduction to Computer Science Compiling Your First Program

Compilers  An engine that works on your behalf to process instructions and allow you to deal with various basic rules of the language  The compiler’s job is to make sure you follow the rules, to require that you provide enough information that the compiler can translate you instructions into languages the components can understand

Compilers Available  Products range from freeware compilers to work environments designed for commercial application development  Borland C++ compiler  CodeWarrior  IBM Visual Age C++  Microsoft Visual C++  GNU freeware  DJGPP freeware ( )

Compilation Process 1. Get the set of instructions from you 2. Review the instructions to see if they violate the rules (syntax) of the language 3. If all the rules are obeyed, create a working file in the language of the computer (machine language) 4. Attach to the working file full instructions for any shortcuts you may have used (linkage) 5. Assemble a final file in machine language

Compiler Files  Source code  Linked/Library file  Object file  Executable file

Source Code  The set of instruction that you will develop on your own for processing by the compiler

Executable Files  A machine-language executable file created when the compilation process is complete  All that is needed to run the program  Not human-readable  Has the extension.EXE  Stored in binary form  Copies may be distributed (portable)  Known as an application

Compiling and Debugging  Executable code will not be created until you correct all of the syntax errors in your source code  Then the fun (with logic errors) begins

Creating Source Code Files Actually Compiling a Program

Creating Source Code  Programmers spend most of their time with source code files  Need to be comfortable with an editor that creates ASCII text files  7-bit representation of all keyboard character  Don’t use a word processor  If an editor in an environment is available, use that, it provides more sophisticated tools

Using the Editor  Save often because there is no autosave in Visual C++  The editor will do matching of delimiters and intelligent indentation

C++ Usages & Conventions  C++ is absolutely case sensitive  For Instance: A is 97 in ASCII and a is 65  Remember: in ASCII {, [, and ( are not equivalent  No keywords in ANSI standard are even partially uppercase  ‘While’ is not a keyword, ‘while’ is  Be careful if you define new keywords  The most common practice in C+++ is to use small letters of the first part of a variable name and capitals for the rest of it

Comments  Document what is happening, why it is happening and other issues  Commentary is ignored by the compiler  C++ has inline, block and documentary comments  Inline comments are within line of code  Use the // symbols  Block comments are long comments delimited with /* and */

Scope Delimiters  A symbol or pair of symbols used to define a region or area which is considered a locale  In programming, many structures need to have their scope defined because they should not affect the entire program  In C++, the symbols ‘{‘ and ‘}’ are used

Literals  Literals are system commands and other pieces of information that the compiler doesn’t understand, and therefore, takes your word for them  In C++, literals are enclosed in straight double quotes " " which is the shift of the apostrophe

Columns and White Space  Modern programming languages are free form with delimiters instead of columns to determine the end of instructions  The ; (semi-colon) is the delimiter used in C++  Use tabs, indents, and blank lines in any manner that makes code easier to understand  Many programming instructions become subordinate to other instructions due to scope and other restrictions. Formatting code to reflect this makes it easier to read

Variables  Variables or identifiers are used to hold information  Usually mixed case with the first letters small and the rest starting with a capital  e.g. theWeight

Color Coding in Visual C++ Editor  Comments are green and are ignored by the compiler  All ANSI keywords are coded in blue  Other code is in plain black  Compiler keywords like cin and cout are also shown in black

Setting Up a Visual C++ Workspace 1. Left-click START 2. In the program section, select Visual Studio or Visual C++ (depending on what is installed) 3. Left click on the Visual C++ icon to load the environment 4. Create a new work area by choosing FILE/NEW 5. Choose FILES tab 6. Click on the C++ Source File to reach the editor i. Add a filename and directory before continuing  e.g. c:/cppFun/myFirstCpp

Setting Up a Visual C++ Workspace 7. Create the directory with START / EXPLORE 8. Double-click the drive letter 9. Choose FILE, NEW FOLDER 10. Left click on FOLDER 11. Change new folder to cppFUN 12. Close Explorer with the X 13. Back in Visual C++, type myFirstCpp in the file box 14. Click OK and get back to the main edit screen

Setting Up a Visual C++ Workspace 15. Enter the source code 16. After entering the program, FILE then SAVE

Why Create New Subdirectories?  You should always use subdirectories to store your files. Visual C++ creates quire a few work files when it generates the executable file for you source code, and they will be easy to dispose of if you keep everything together in one convenient place.  Under no circumstances should you use the root (C:\) directory except on a floppy disk (A:\).

Running the Program 1. Press the REBUILD ALL button. It has two arrows in a box 2. Press the RUN button. It is a red exclamation point

Disk Space Issues  Text files are insignificant in terms of space  However, six other files are created every time something is compiled; some get around 95% full  Highlighting the disk in are 3 or 4 times larger than the source  You can delete anything but the file with the.cpp suffix; everything else can be recreated

Recompiling 1. Open the file by going the file you stored it in and double clicking on it 2. Scan the source code for obvious errors before attempting to compile 3. Attempt to compile using the COMPILE button or choosing the first option on the BUILD menu 4. Answer Yes to use the default project workspace – The lower window will be active and the compile will occur 5. Note the number of errors and warnings – These need to be dealt with before executable code is created

Working in a Lab Environment  The following issues are magnified working in a laboratory environment:  Viruses  Scan disks transferring between the lab and home  Plagiarism  Beware of shoulder surfing, temp directories, shared directories, discarded print and new print  Name things vaguely and delete what you are done with  Theft  Take your floppies and Zip Disks with you  Malicious mischief