Mr. Dave Clausen La Cañada High School

Slides:



Advertisements
Similar presentations
C++ Basics March 10th. A C++ program //if necessary include headers //#include void main() { //variable declaration //read values input from user //computation.
Advertisements

What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
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.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
1 September 6, 2005CS150 Introduction to Computer Science I What Actions Do We Have Part 1 CS150 Introduction to Computer Science I.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Chapter 7. 2 Objectives You should be able to describe: The string Class Character Manipulation Methods Exception Handling Input Data Validation Namespaces.
C++ PROGRAMMING Dr. Parvis Partow CSULA Revised by Mr. Dave Clausen La Cañada High School.
Basic Elements of C++ Chapter 2.
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.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Introduction to C++ Programming
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
CSCI 1730 January 17 th, 2012 © by Pearson Education, Inc. All Rights Reserved.
Introduction to C++ - How C++ Evolved Most popular languages currently: COBOL, Fortran, C, C++, Java (script) C was developed in 1970s at AT&T (Richie)
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.
Current Assignments Homework 3 is due tonight. Iteration and basic functions. Exam 1 on Monday.
COMPUTER PROGRAMMING. A Typical C++ Environment Phases of C++ Programs: 1- Edit 2- Preprocess 3- Compile 4- Link 5- Load 6- Execute Loader Primary Memory.
1 CS161 Introduction to Computer Science Topic #3.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
CSC1201: Programming Language 2 Lecture 1 Level 2 Course Nouf Aljaffan (C) CSC 1201 Course at KSU1.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Chapter 2: Introduction to C++. Language Elements Keywords Programmer-defined symbols (identifiers) Operators Punctuation Syntax Lines and Statements.
Objective: Students will be able to: Declare and use variables Input integers.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Learners Support Publications Introduction to C++
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
LESSON 2 Basic of C++.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.
Looping I (while statement). CSCE 1062 Outline  Looping/repetition construct  while statement (section 5.1)
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
1 Sections 3.3 – 3.4 Terminal I/O and Comments Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Basic concepts of C++ Presented by Prof. Satyajit De
C++ First Steps.
Great way to learn is by example so fire up Visual Studios C (at home make sure you custom install with C++ - no longer default) by Deborah R. Fowler.
C++ Programming: Presentation 1
Chapter Topics The Basics of a C++ Program Data Types
Topic Pre-processor cout To output a message.
Engineering Problem Solving With C An Object Based Approach
What Actions Do We Have Part 1
LESSON 2 Basic of C++.
Basic Elements of C++.
Basic Elements of C++ Chapter 2.
Chapter 2 – Getting Started
CS 1430: Programming in C++ Turn in your Quiz1-2 No time to cover HiC.
Random Number Generation
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
Basic Input and Output C++ programs can read and write information using streams A simple input stream accepts typed data from a keyboard A simple output.
Starting Out with C++: From Control Structures through Objects
Code::Block vs Visual C++
Introduction to C++ Introduced by Bjarne Stroustrup of AT&T’s Bell Laboratories in mid-1980’s Based on C C++ extended C to support object-oriented programming.
CS150 Introduction to Computer Science 1
Control Structures Part 1
Engineering Problem Solving with C++ An Object Based Approach
Engineering Problem Solving with C++ An Object Based Approach
Lecture 2 Fall 2011 September 13-15, 2011 Ghufran Ahmed
CHAPTER 4 File Processing.
What Actions Do We Have Part 1
Using string type variables
COMS 261 Computer Science I
COMS 261 Computer Science I
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
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.
Chapter 1 c++ structure C++ Input / Output
Presentation transcript:

Mr. Dave Clausen La Cañada High School C++ PROGRAMMING Mr. Dave Clausen La Cañada High School

Sample Program //Sample Program // Comments here #include <iostream> using namespace std; int main( ) { cout << “Hello, World!”; cin.get( ); return 0; }

C++ Basics Every C++ program should have the following lines: using namespace std; int main ( ) C++ statements should reside between { and }. The last statement should be return 0; For I/O purpose the following statement should be present #include <iostream> Use // to insert comments as part of your documentation.

C++ General Format //General Format //Date //Description of the Program // #include <iostream> using namespace std; int main( ) { //Supply your own declaration statements . . cin.get( ); return 0; }

Predict the Output //What is the output? #include <iostream> using namespace std; int main( ) { cout << “Hello, World!”; cout<<“My first program!”; cin.get( ); return 0; }

Predict the Output 2 //What is the output? // New Lines With endl #include <iostream> using namespace std; int main( ) { cout << “Hello, World!” <<endl; cout<<“My first program!”<<endl; cin.get( ); return 0; }

Input and Output Objects common input cin common output cout Format: cout << expression-1<<expression-2 …; Semicolon is used to terminate the statement. Example: cout << “Have a nice day.” <<endl;

How To Make a Program Pause The command: cin.get(); will wait for the user to press any key on the keyboard. It is usually good to have a cout statement preceding this so the user knows why the program is stopping (user friendly).

Sample Program Example //SampleProgram.cpp // New Lines With endl – this is an L not a 1 (one) #include <iostream> using namespace std; int main( ) { cout << “Hello, World!” << endl; cout << “My first program!” << endl; cout<<endl<<endl<<endl; cout << “Press any key to continue…”<< endl; cin.get( ); return 0; }

Program 2A Sample output for program 2A program2A.cpp HelloWorld Java C++ Program