CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Summer 2014 1.

Slides:



Advertisements
Similar presentations
Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Advertisements

CMPUT 101 Lab # 5 October 22, :00 – 17:00.
Problem Solving and Program Design Programming. COMP104 Lecture 3 / Slide 2 Problem Solving Process l Define and analyze the problem. l Develop a solution.
Problem Solving and Program Design. COMP104 Problem Solving / Slide 2 Our First Program // a simple program #include using namespace std; int main() {
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 2: Your First Program.
Your First C++ Program Aug 27, /27/08 CS 150 Introduction to Computer Science I C++  Based on the C programming language  One of today’s most.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
C# Programming: From Problem Analysis to Program Design1 2 Your First C# Program.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
Variables in Java Part 2. ICS-3M1 - Mr. Martens - Variables Part 2 Recall the “int” Data Types When you divide one integer by another – you always get.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Hello World 2 What does all that mean?.
CSC 107 – Programming For Science. Announcements  Tutors available MTWR in WTC206/WTC208  Special lab (with Macs) & not in the Tutoring Center  Can.
General Programming Introduction to Computing Science and Programming I.
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
Programming Lifecycle
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
Creating your first C++ program
Chapter 2 Overview of C++. A Sample Program // This is my first program. It calculates and outputs // how many fingers I have. #include using namespace.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Spring 2014.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
6/3/2016 CSI Chapter 02 1 Introduction of Flow of Control There are times when you need to vary the way your program executes based on given input.
Chapter 0 Getting Started. Objectives Understand the basic structure of a C++ program including: – Comments – Preprocessor instructions – Main function.
Chapter 2 Introduction to C++ Department of Computer Science Missouri State University.
1 Original Source : and Problem and Problem Solving.ppt.
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
C++ Basics L KEDIGH. Objectives 1. basic components of a c++ program using proper terminology and programming conventions adopted for this class. 2. List.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Lesson - 2. Introduction When we make a program we must follow some steps, called Programming Development Life Cycle (PDLC). Programming steps are five:
Programming Errors. Errors of different types Syntax errors – easiest to fix, found by compiler or interpreter Semantic errors – logic errors, found by.
Java FilesOops - Mistake Java lingoSyntax
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Dayu Zhang 9/10/2014 Lab03. Outline Brief Review of the 4 Steps in Hello.cpp Example Understand endl and \n Understand Comment Programming Exercise -
CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Summer
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Summer
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. Chapter 2 C++ Basics.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Software Engineering Algorithms, Compilers, & Lifecycle.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
Basic concepts of C++ Presented by Prof. Satyajit De
Introduction to Computing Science and Programming I
CMPT 201.
ANNOUNCEMENT The missed lecture will be made up this Monday evening in the Tech PC classroom (MG51). A tentative time interval is 6:30-8:00. The exact.
Chapter 1 Introduction to Computers, Programs, and Java
Completing the Problem-Solving Process
CSCI-1411 Fundamentals of Computing Lab
CSC113: Computer Programming (Theory = 03, Lab = 01)
Chapter 2 Elementary Programming
Escape sequences: Practice using the escape sequences on the code below to see what happens. Try this next code to help you understand the last two sequences.
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Subject:Object oriented programming
C++ Basics CSci 107. A C++ program //include headers; these are modules that include functions that you may use in your //program; we will almost always.
CS31 Discussion 1D Fall18: week 2
Chapter 1 c++ structure C++ Input / Output
Introduction to Algorithms and Programming COMP151
Presentation transcript:

CSCI-1411 F UNDAMENTALS O F C OMPUTING L AB Shane Transue Summer

Lab 1: Introduction to Programming and the Translation Process 2  Overview:  Components of a Lab Lab Sections (1.1, 1.2,...) Comments Style Exercises Writing your own program Design Documents  Lab 1 Syntax Errors Logic Errors Runtime Errors

C++ Comments and Exercise Questions 3  Comments are ignored by the C++ compiler (GCC)  Utilized to explain ‘what’ the code does or ‘why’  Use comments at the end of your source file to answer the questions to the exercises  C++ Has two forms of comments: Line Comments Block Comments

C++ Comments and Exercise Questions 4  Line and (inline) Comments // This is a line comment, everything on this line is ignored int main() { int radius = 4; // The radius of the user circle. }  Block Comments int main() { double c = 1.0; } /* * Block Comment: * Here, everything is a comment and will be * ignored. Use this space to answer the exercise questions. */

C++ Quick Style Guide 5  Quick Rules for Proper Styling  Properly indent code  Ensure that the “{ }” curly braces are well formed  Use adequate variable names: int a, b, c, d, e, f;  What do any of these mean? int userRadius, calculatedCircumference; // Better  Example

C++ Quick Style Guide 6 #include using namespace std; int main() { int numberOfApples= 4; // If there are a lot of apples, then print a message // to the user. if ( numberOfApples >= 4 ) { cout << "That is a lot of apples." << endl; } return 0; }

C++ Quick Style Guide 7 #include using namespace std;int main(){int numberOfApples=4;if(numberOfApples>=4){ cout<<"That is a lot of apples."<<endl;}return 0;}  Source code is for humans! The Compiler doesn’t care.

Lab 1: Introduction to Programming and the Translation Process  1.1 Opening, Compiling and Running your First Program  (firstprog.cpp)  1.2 Compiling a Program with a Syntax Error  Syntax Errors are detected by the compiler (g++)  (semiprob.cpp)  1.3 Running a Program with a Run Time Error  Does something unexpected that may prevent the program from continuing execution (Division by zero)  (runprob.cpp)  1.4 Working with Logic Errors  Logical errors are harder to detect  The program compiles and executes, but does not do what we ‘intended’  (logicprob.cpp) 8

Lab 1: Introduction to Programming and the Translation Process 9  1.5 Writing Your First Program (Not optional)  Write a design document Description of the algorithm Input / Output Flow-Chart, diagrams, Explanations, Equations Expected Results Save as (*.doc, *.docx, *.pdf, *.txt, *.rtf)  Save this source file as: ( kilotomiles.cpp )

Lab 1: Introduction to Programming and the Translation Process 10  Submission File Checklist  Submit all files on Canvas (One at a time or all of them in a single zip file). Be sure to include all source files and documents.  1.1 firstprog.cpp  1.2 semiprob.cpp  1.3 runprob.cpp  1.4 logicprob.cpp  1.5: kilotomiles.cpp  1.5: designdocument.pdf