C++ PROGRAMMING Dr. Parvis Partow CSULA Revised by 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

Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
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.
CS 117 Section 2 + KNET Computer accounts – ed to KNET students –Change password Homework 1 Lab Tutors –In lab for next 2 weeks –Will help you with.
Basic Input/Output and Variables Ethan Cerami New York
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.
Input and Output in Console Mode UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
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)
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - HelloWorld Application: Introduction to.
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.
CS31: Introduction to Computer Science I Discussion 1A 4/9/2010 Sungwon Yang
Chapter 02 (Part III) Introduction to C++ Programming.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Unit 3, Lesson 3 Math Operations, Assignment Operators, and Arithmetic Operators Mr. Dave Clausen La Cañada High School
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
Program style. Global area Place comment s at beginning of the program: 1.purpose 2.author 3.the date the program was written 4.the data and description.
CHAPTER 7 DATA INPUT OUTPUT Prepared by: Lec. Ghader R. Kurdi.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Review the following : Flowcharting Variable declarations Output Input Arithmetic Calculations Conditional Statements Loops.
Control Structures (B) Topics to cover here: Sequencing in C++ language.
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
Software Engineering Object-Centered Design. Problem Solving Does anyone scuba dive? Let’s solve this scuba-diving problem: Write a program that, given.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
1 8/31/05CS150 Introduction to Computer Science 1 Hello World!
Unit 3 Lesson 6 Input and Output Streams with modifications by Mr. Dave Clausen.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Learners Support Publications Introduction to C++
Enumerated Types Mr. Dave Clausen La Cañada High School.
Literals A literal (sometimes called a constant) is a symbol which evaluates to itself, i.e., it is what it appears to be. Examples: 5 int literal
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
LESSON 2 Basic of C++.
Computer Programming Arrays 1. Question #1 2 Question Choose the correct answer..
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.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output Samples.
INPUT & OUTPUT 10/20/2016Department of Computer Science, UOM | Introduction | Fakhre Alam.
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++ Programming: Presentation 1
C++ Basic Input and Output (I/O)
Chapter Topics The Basics of a C++ Program Data Types
What Actions Do We Have Part 1
Chapter 2 Introduction to C++ Programming
LESSON 2 Basic of C++.
Basic Elements of C++.
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
CS150 Introduction to Computer Science 1
CS150 Introduction to Computer Science 1
Mr. Dave Clausen La Cañada High School
Engineering Problem Solving with C++ An Object Based Approach
What Actions Do We Have Part 1
COMS 261 Computer Science I
CPP Programming Language
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.
Introduction to Programming - 1
Chapter 1 c++ structure C++ Input / Output
Object-Centered Design
Getting Started With Coding
Presentation transcript:

C++ PROGRAMMING Dr. Parvis Partow CSULA Revised by Mr. Dave Clausen La Cañada High School

Sample Program //Sample Program // Comments here #include #include int main( ) { cout << “Hello, World!”; getch( ); return 0; }

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

C++ General Format //General Format //Date //Description of the Program // #include #include int main( ) { //Supply your own declaration statements.. getch( ); return 0; }

Predict the Output //What is the output? #include #include int main( ) { cout << “Hello, World!”; cout<<“My first program!”; getch( ); return 0; }

Predict the Output 2 //What is the output? // New Lines With endl #include #include int main( ) { cout << “Hello, World!” <<endl; cout<<“My first program!”<<endl; getch( ); 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.”;

How To Make a Program Pause n The command: getch(); will wait for the user to press any key on the keyboard. n You must have #include to make this work. n It is usually good to have a cout statement preceding this so the user knows why the program is stopping (user friendly).

Clear Screen n The command: clrscr( ); will clear all text from the text screen. n You must have #include to make this work.

Delay Command n The command: delay (100); will make the program wait for 100 milliseconds before proceeding with the next command. n Delay time is measured in milliseconds, therefore, a delay of 1000 milliseconds equals 1 second. n You must have #include in order for this to work.

Delay Time Constants n When using the delay command, it is best to use a constant. const int DELAY_TIME = 100; n This must occur AFTER the #includes and BEFORE int main(). n Then use the command delay (DELAY_TIME);