1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.

Slides:



Advertisements
Similar presentations
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
Advertisements

 C++ programming facilitates a disciplined approach to program design. ◦ If you learn the correct way, you will be spared a lot of work and frustration.
What Data Do We Have? Sections 2.2, 2.5 August 29, 2008.
1 Lecture-4 Chapter 2 C++ Syntax and Semantics, and the Program Development Process Dale/Weems/Headington.
1 9/1/06CS150 Introduction to Computer Science 1 What Data Do We Have? CS 150 Introduction to Computer Science I.
© 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5/e Starting Out with C++: Early Objects 5 th Edition Chapter 2 Introduction.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Sixth.
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 2: Introduction to C++.
Basic Elements of C++ Chapter 2.
Programming is instructing a computer to perform a task for you with the help of a programming language.
Copyright 2003 Scott/Jones Publishing Brief Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
CSC 125 Introduction to C++ Programming Chapter 2 Introduction to C++
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Seventh.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
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.
Introduction to C The Parts of a C++ Program –Anatomy of a simple C++ program.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Lecture 3: The parts of a C++ program Professor: Dr. Miguel Alonso Jr. Fall 2008 CGS2423/COP1220.
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.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE 1 st semester H 1 King Saud University College of Applied studies and Community Service Csc 1101 By:
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
THE BASICS OF A C++ PROGRAM EDP 4 / MATH 23 TTH 5:45 – 7:15.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
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.
Chapter 2 part #1 C++ Program Structure
A first program 1. #include 2. using namespace std; 3. int main() { 4. cout
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Sixth.
Introducing C++ Programming Lecture 3 Dr. Hebbat Allah A. Elwishy Computer & IS Assistant Professor
Chapter 2: Introduction to C++. Language Elements Keywords Programmer-defined symbols (identifiers) Operators Punctuation Syntax Lines and Statements.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects.
Chapter 2: Introduction to C++. Outline Basic “Hello World!!” Variables Data Types Illustration.
Introduction to C++.  Computers: CPU, Memory & Input / Output (IO)  Program: Sequence of instructions for the computer.  Operating system: Program.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Introduction to C++
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2: Introduction to C++ Starting Out with C++ Early Objects Seventh.
Objective Write simple computer program in C++ Use simple Output statements Become familiar with fundamental data types.
1 Structure of Simple C++ Program Chapter 1 09/09/13.
1 8/30/06CS150 Introduction to Computer Science 1 Your First C++ Program.
Lecture 4 Computer Programming // sample C++ program #include using namespace std; int main() { cout
1 Chapter 2 Introduction to C++. 2 Topics 2.1 Parts of a C++ Program 2.2 The cout Object 2.3 The #include Directive 2.4 Variables and Constants 2.5 Identifiers.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 2-1 Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to 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.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 2: Introduction to C++
Lecture 2 Variables, Types, Operators Sampath Jayarathna Cal Poly Pomona Based on slides created by Bjarne Stroustrup & Tony Gaddis CS 128 Introduction.
Chapter 2 of C++ How to Program, 10/e © by Pearson Education, Inc. All Rights Reserved.
C++ First Steps.
C++ Programming: Presentation 1
Chapter Topics The Basics of a C++ Program Data Types
Topic Pre-processor cout To output a message.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
What Actions Do We Have Part 1
Chapter 2: Introduction to C++
Chapter 2 part #1 C++ Program Structure
Basic Elements of C++.
Chapter 2: Introduction to C++
Basic Elements of C++ Chapter 2.
Chapter 2 – Getting Started
C++ fundamentals Lecture 1, Chapter 2 – pp /22/2018 Y K Choi.
2.1 Parts of a C++ Program.
Chapter 2: Introduction to C++.
Lecture 2 Variables, Types, Operators
COMS 261 Computer Science I
Introduction to Programming - 1
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program

2. Q: Mention parts of c++ program 1. Special characters 2. cout > objects 3. endl manipulator 4. \n escape sequence #include directive(not part of c++ program)

3 1. Special Characters (العلامات الخاصة) Q: Given the following table fill in the spaces CharacterNameMeaning // Double slashBeginning of a comment # Pound signBeginning of preprocessor directive Open/close bracketsEnclose filename in #include ( ) Open/close parentheses Used when naming a function { } Open/close braceEncloses a group of statements " Open/close quotation marks Encloses string of characters ; SemicolonEnd of a programming statement

4 2. The cout > object) cout<< 1. Displays output on the computer screen(شاشة) 2. You use operator << to send output to cout: Ex: 3. can be used to send more than one item to cout: cout << "Programming is fun!”; cout << "Hello " << "there!"; or cout << "Hello "; cout << "there!";

5 3. The endl Manipulator You can use the endl manipulator (معالج) to start a new line of output. You can use the endl manipulator (معالج) to start a new line of output. This will produce two lines of output: This will produce two lines of output: Programming is fun cout << "Programming is" << endl; cout << "fun!";

6 - This produces(ينتج عنه) one line of output: This produces(ينتج عنه) one line of output: cout << "Programming is "; cout << "fun!“ Programming is fun! Note: We use cin>> for input instead of cout<< For output

7 4.The \n Escape Sequence You can also use the \n escape sequence to start a new line of output. This will produce two lines of output: cout << "Programming is\n"; cout << "fun!";

8 5. The #include Directive 1. Inserts(تدرج) the contents(محتويات) of another file into the program 2. This is a preprocessor directive, not part of C++ language 3. #include lines not seen by compiler 4. Do not place a semicolon at end of #include line

9 - Q: Mention the function of endl to start a new line of output. Q: Mention the function of \n to start a new line of output. Q: Mention the function of #include Inserts(تدرج) the contents(محتويات) of another file into the program Mention the function of cout<< Displays output on the computer screen(شاشة) Mention the function of cin>> Mention the function of cin>> Insert inputs on computer screen

10 NO The Parts of a C++ Program // sample C++ program #include #include using namespace std; int main() { cout << "Hello, there!"; return 0; } preprocessor directive Comment(تعليق) which namespace to use beginning of function named main beginning of block for main output statement end of block for main string literal send 0 to operating system