CPS120: Introduction to Computer Science Introduction to C++

Slides:



Advertisements
Similar presentations
Introducing JavaScript
Advertisements

IT151: Introduction to Programming
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Introduction to C++ September 12, Today’s Agenda Quick Review Check your programs from yesterday Another Simple Program: Adding Two Numbers Rules.
Introduction to C Programming
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 2: Your First Program.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Chapter 2: Introduction to C++.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
Introduction to C Programming
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Chapter 3: Introduction to C Programming Language C development environment A simple program example Characters and tokens Structure of a C program –comment.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
CPS120: Introduction to Computer Science Lecture 8.
Chapter 3 Getting Started with C++
Goals of Course Introduction to the programming language C Learn how to program Learn ‘good’ programming practices.
The Java Programming Language
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
Programming With C.
CPS120: Introduction to Computer Science Compiling Your Programs Using Visual C++
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
CPS120: Introduction to Computer Science
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Sharda University P. K. Mishra (Asst.Prof) Department of Computer Science & Technology Subject Name: Programming Using C Sub Code: CSE-106 Programming.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
Introduction to programming in the Java programming language.
CPS120: Introduction to Computer Science Compiling Your First Program.
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Anatomy of a Java Program. AnotherQuote.java 1 /** A basic java program 2 * 3 Nancy Harris, James Madison University 4 V1 6/2010.
Agenda Computer Languages How to Write a Simple C Program
1 JavaScript in Context. Server-Side Programming.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction to Computers, Programs,
12/14/2016CS150 Introduction to Computer Science 1 Announcements  Website is up!   All lecture slides, assignments,
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
SUMMARY OF CHAPTER 2: JAVA FUNDAMENTS STARTING OUT WITH JAVA: OBJECTS Parts of a Java Program.
Programming Basics - RobotC Introduction to Robotics.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
STRUCTURED PROGRAMMING Complete C++ Program. Content 2  Main Function  Preprocessor directives  User comments  Escape characters  cout statement.
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
CSC201: Computer Programming
Introduction to the C Language
Chapter 1 Introduction to Computers, Programs, and Java
Chapter 2, Part I Introduction to C Programming
Algorithms Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
Introduction to C Topics Compilation Using the gcc Compiler
Intro to Java.
Introduction Java Chapter 3.
Programming Vocabulary.
2.1 Parts of a C++ Program.
Chapter 1: Computer Systems
Programming Basics - RobotC
The C Programming Language
A programming language
Chapter 2: Introduction to C++.
Lecture Notes - Week 2 Lecture-1. Lecture Notes - Week 2 Lecture-1.
CPS120: Introduction to Computer Science
Computer Programming-1 CSC 111
Presentation transcript:

CPS120: Introduction to Computer Science Introduction to C++

A Simple C++ Program Comments // Simple C++ Program // // Purpose: To demonstrate the // parts of a simple C++ program Compiler Directive #include Main Functionmain ( ) Braces{ Statementscout << "This is a simple program "; return 0; }

C++ and Blank Space C++ allows for great flexibility in the spacing and layout of code Use this feature to make it easier for you as a human being to read the code

Formatting in C++ 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

Uppercase or Lowercase Be careful to use the same combination of uppercase or lowercase lettering when you enter source code Commands and other reserved words are all lower case

Characteristics of a C++ Program Comments Compiler Directives Functions Braces Statements

Comments Explain the purpose of a program Keep notes regarding changes to source code Store details about the programmers for future reference Explain parts of the program

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 */

Sample Comments At the start of the program /************************************************** ** Miles Per Gallon** ** Programmer: Paul J. Millis** ** Purpose: Calculate mile per gallon and price per mile** ** given miles, gallons and gas price** *************************************************/ Within specific lines of code float PricePerMile = 0.00;//store the price per mile float MilesPerGallon = 0.0;//stores the miler per gallon achieved

Compiler Directives Instructions to the compiler rather than part of the C++ language –Most common directive is #include For Example: #include –A.h file is a header file. It serves as a link between program code and standard C++ code needed to make programs run

Functions A function is a block of code that carries out a specific task Every C++ program has a main function that executes when a program initiates –Includes open parenthesis to designate a function –Ends with a return 0; statement

Braces Mark the beginning and ending of blocks of related code –Every opening brace must have a closing brace

Statements Functions contain statements that consist of instructions or commands that make the program work

Semicolons There must be a semicolon after every statement –To tell the compiler that the statement is complete –Function definitions and compiler directives are exempt