Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow World Using C/C++ Dr. Ming Zhang.

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

IT151: Introduction to Programming
Introduction to C++ Programming. A Simple Program: Print a Line of Text // My First C++ Program #include int main( ) { cout
 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.
A simple C++ program /* * This program prints the phrase "Hello world!" * on the screen */ #include using namespace std; int main () { cout
CS31: Introduction to Computer Science I Discussion 1A 4/2/2010 Sungwon Yang
Basic Elements of C++ Chapter 2.
Introduction to C++ Programming
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)
 2003 Prentice Hall, Inc. All rights reserved. 1 Introduction to C++ Programming Outline Introduction to C++ Programming A Simple Program: Printing a.
Chapter 3 Getting Started with C++
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.
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.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Basic Elements of C++ Chapter 1.
Week 1 Algorithmization and Programming Languages.
C++ Programming: Basic Elements of C++.
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:
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Copyright © 2012 Pearson Education, Inc. Chapter 2: Introduction to C++
C++ How to Program, 8/e © by Pearson Education, Inc. All Rights Reserved.
C++ How to Program, Late Objects Version, 7/e © by Pearson Education, Inc. All Rights Reserved.
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++
1 A simple C++ program // ======================================================= // File:helloworld.cpp // Author:Vana Doufexi // Date:1/4/2006 // Description:Displays.
Chapter 2 part #1 C++ Program Structure
Chapter 2: Introduction to C++. Language Elements Keywords Programmer-defined symbols (identifiers) Operators Punctuation Syntax Lines and Statements.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
1 CISC181 Introduction to Computer Science Dr. McCoy Lecture 2 September 3, 2009.
CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING Dr. Shady Yehia Elmashad.
 2003 Prentice Hall, Inc. All rights reserved Basics of a Typical C++ Environment C++ systems –Program-development environment –Language –C++
Arithmetic Operations (L05) * Arithmetic Operations * Variables * Declaration Statement * Software Development Procedure Problem Solving Using C Dr. Ming.
Chapter 2 Creating a C++ Program. Elements of a C++ Program Four basic ways of structuring a program Four basic ways of structuring a program 1.Sequencing.
1 17/4/1435 h Monday Lecture 3 The Parts of a C++ Program.
CHAPTER 3 COMPLETING THE PROBLEM- SOLVING PROCESS AND GETTING STARTED WITH C++ An Introduction to Programming with C++ Fifth Edition.
Lecture 4 Computer Programming // sample C++ program #include using namespace std; int main() { cout
2.1 The Part of a C++ Program. The Parts of a C++ Program // sample C++ program #include using namespace std; int main() { cout
Chapter 2 of C++ How to Program, 10/e © by Pearson Education, Inc. All Rights Reserved.
C++ First Steps.
© by Pearson Education, Inc. All Rights Reserved.
Chapter 1.2 Introduction to C++ Programming
Programming what is C++
Chapter Topics The Basics of a C++ Program Data Types
Chapter 1.2 Introduction to C++ Programming
Computer Programming BCT 1113
Chapter 1.2 Introduction to C++ Programming
Topic Pre-processor cout To output a message.
CHAPTER 2 PART #1 C++ PROGRAM STRUCTURE
Chapter 1: Introduction to computers and C++ Programming
Introduction to C++ Programming
Introduction to C++ Programming
Chapter 2 Introduction to C++ Programming
Chapter 1.2 Introduction to C++ Programming
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.
CSC201: Computer Programming
Chapter 2, Part I Introduction to C Programming
Chapter 2 part #1 C++ Program Structure
Basic Elements of C++.
Basic Elements of C++ Chapter 2.
Chapter 2 Elementary Programming
2.1 Parts of a C++ Program.
Value returning Functions
Functions Pass By Value Pass by Reference
1.2 Function and Class Names
Introduction to C++ Programming
Chapter 2: Introduction to C++.
Introduction to Programming - 1
Chapter 1 c++ structure C++ Input / Output
Chapter 2 part #1 C++ Program Structure
Presentation transcript:

Hello World Using C++ (L03) * Introduction C++ * Programming Style * Hello World Using C++ Hollow World Using C/C++ Dr. Ming Zhang

Identifiers Identifiers are composed of any combination of letters, digits, and underscore ( _ ) selected according to the following rules: 1. The first character of the name must be a letter or underscore. 2. Only letters, digits, or underscore may follow the initial letter. Blank spaces and other special characters are not allowed. 3. A function name cannot be one of the keyword reserved for C The maximum number of characters in a function name is 31 characters. Hollow World Using C/C++ Dr. Ming Zhang

Examples of Invalid Identifiers * 1AB3: Begins with a number, which violates rule 1. * E*6: Contains a special character, which violates rule 2. * while: while is a keyword reserved for C++, which violates rule 3. Hollow World Using C/C++ Dr. Ming Zhang

Keywords for C++ autobreakcasechar constcontinuedefaultdo doubleelseenumextern floatforgotoif intlongregisterreturn shortsignedsizeofstatic structswitchtypedefunion unsignedvoidwhile class Hollow World Using C /C++ Dr. Ming Zhang

main( ) Function *main( ) function is used to provide for the orderly placement and execution of all other functions. *The reserved word main tells the compiler where program execution is to begin, each C program must have one and only one function called main( ). * The main( ) function is commonly used to invoke other functions by calling them in the sequence in which they are to operate, this function is sometimes referred to as a driver function. Hollow World Using C/C++ Dr. Ming Zhang

Structure of main( ) function What type of data, Function What type of data if any, is returned name (argument), if any, from the function. is sent into the function Function header void main (void) { Function Body Program statements in here; } Each statement inside the function must end with a semicolon(;) Hollow World Using C /C++ Dr. Ming Zhang

Standard Output Stream- cout * Standard Output Stream cout * Example cout << “Welcome to C++!\n”; instructs the computer to print on the screen the string of characters contained between the quotation marks. Hollow World Using C/C++ Dr. Ming Zhang

Hello World Using C++ #include using std::cout; // program uses cout using std:cin; // Program uses cin using std:endl; // program uses endl int main ( ) { cout << “Hello World!” << endl; return 0; // program ended successfully } Hollow World Using C /C++ Dr. Ming Zhang

Home Work Using C++ to show your name on the screen. The output of screen much be : My first name is: Ming My last name is: ZHANG Hollow World Using C /C++ Dr. Ming Zhang