C++ Language

In: Business and Management

Submitted By Python
Words 798
Pages 4
cplusplus.com

C++ Language Tutorial

Written by: Juan Soulié Last revision: June, 2007

Available online at:

http://www.cplusplus.com/doc/tutorial/
The online version is constantly revised and may contain corrections and changes

The C++ Language Tutorial

This document and its content is copyright of cplusplus.com © cplusplus.com, 2008. All rights reserved. Any redistribution or reproduction of part or all of the content in any form is prohibited other than to print a personal copy of the entire document or download it to a local hard disk, without modifying its content in any way (including, but not limited to, this copyright notice). You may not, except with express written permission from cplusplus.com, distribute the content of this document. Nor may you transmit it or store it in any other website or other form of electronic retrieval system.
2

© cplusplus.com 2008. All rights reserved

The C++ Language Tutorial

Table of contents
Table of contents ...............................................................................................................................3 Introduction ......................................................................................................................................5 Instructions for use ................................................................................................................................... 5 Basics of C++ ......................................................................................................................................7 Structure of a program ............................................................................................................................. 7 Variables. Data Types. ............................................................................................................................. 11 Constants…...

Similar Documents

C++Language Compasion

...++Starting Out with Programming Logic and Design, 3rd Edition By Tony Gaddis C++ Language Companion or Copyright © 2013 Pearson Education, Inc. Table of Contents Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 Chapter 10 Chapter 11 Chapter 12 Chapter 13 Chapter 14 Introduction 3 Introduction to Computers and Programming 4 Input, Processing, and Output 9 Functions 19 Decision Structures and Boolean Logic 27 Repetition Structures 41 Value-Returning Functions 49 Input Validation 59 Arrays 61 Sorting and Searching Arrays 72 Files 77 Menu-Driven Programs 86 Text Processing 89 Recursion 95 Object-Oriented Programming 97 Page 2 Introduction Welcome to the C++ Language Companion for Starting Out with Programming Logic and Design, 3rd Edition, by Tony Gaddis. You can use this guide as a reference for the C++ Programming Language as you work through the textbook. Each chapter in this guide corresponds to the same numbered chapter in the textbook. As you work through a chapter in the textbook, you can refer to the corresponding chapter in this guide to see how the chapter's topics are implemented in the C++ programming language. In this book you will also find C++ versions of many of the pseudocode programs that are presented in the textbook. Note: This booklet does not have a chapter corresponding to Chapter 15 of your textbook because C++ does not provide a GUI programming library. Page 3 Chapter 1 This chapter......

Words: 1609 - Pages: 7

C Language

...Computer Programming Language Week 11 Data Files Objectives Understand Text and Binary Files  Declaring, Opening, and Closing File Streams  Reading from and Writing to Text Files  Passing and Returning Filenames  Reading from and Writing to Binary Files (Optional)  2 Files   File: collection of data that is stored together under a common name, usually on a disk, magnetic tape, or CD-ROM Each file has a unique filename, referred to as the file’s external name  For example, prices.dat and info.txt 3 Text and Binary Files  A file can be thought as an array of bytes. Characters Displayed 768A Code page: ASCII Code Software Interpretation Binary numbers, in decimal numbers: 55 54 56 65 4 ASCII Table 5 Other Code Page* How this text file is stored in computer? Hello 您好 Encode simplified Chinese • GB2312 • GB18030 • UTF-8 6 Declaring, Opening, and Closing File Streams  To store and retrieve data outside a C program, you need two items:   A file A file stream  File stream: one-way transmission path used to connect a file stored on a physical device to a program   Input file stream: receives data from a file into a program Output file stream: sends data to a file 7 File Streams 8 Declaring a File Stream    File stream is a data structure For each file that your program uses, a file stream must be named (declared) and created (opened) Declare a file stream ...

Words: 1171 - Pages: 5

The C Programming Language

...The C programming Language The C programming Language By Brian W. Kernighan and Dennis M. Ritchie. Published by Prentice−Hall in 1988 ISBN 0−13−110362−8 (paperback) ISBN 0−13−110370−9 Contents • Preface • Preface to the first edition • Introduction 1. Chapter 1: A Tutorial Introduction 1. Getting Started 2. Variables and Arithmetic Expressions 3. The for statement 4. Symbolic Constants 5. Character Input and Output 1. File Copying 2. Character Counting 3. Line Counting 4. Word Counting 6. Arrays 7. Functions 8. Arguments − Call by Value 9. Character Arrays 10. External Variables and Scope 2. Chapter 2: Types, Operators and Expressions 1. Variable Names 2. Data Types and Sizes 3. Constants 4. Declarations 5. Arithmetic Operators 6. Relational and Logical Operators 7. Type Conversions 8. Increment and Decrement Operators 9. Bitwise Operators 10. Assignment Operators and Expressions 11. Conditional Expressions 12. Precedence and Order of Evaluation 3. Chapter 3: Control Flow 1. Statements and Blocks 2. If−Else The C programming Language 1 The C programming Language 3. Else−If 4. Switch 5. Loops − While and For 6. Loops − Do−While 7. Break and Continue 8. Goto and labels 4. Chapter 4: Functions and Program Structure 1. Basics of Functions 2. Functions Returning Non−integers 3. External Variables 4. Scope Rules 5. Header Files 6. Static Variables 7. Register Variables 8. Block Structure 9. Initialization 10. Recursion 11. The C Preprocessor 1. File Inclusion 2. Macro......

Words: 89362 - Pages: 358

Language

...“American fearfulness expresses itself in three curious ways: A, B, and C.” This tells your reader you have three main points, and that they are going to be discussed in your paper in this order. However, this kind of thesis statement may be too formulaic or too constricting for all papers. You could instead say, “Americans are fearful, and this fearfulness manifests itself in the form of violence.” The reader knows that you will then show examples of American fearfulness, and will tell how that fearfulness turns into violence. Again, your thesis statement is a contract. If you suggest a structure or a particular ordering principle and then abandon it, the reader will feel betrayed, irritated and confused. The Thesis Statement Checklist • Does my thesis sentence attempt to answer (or at least explore) a challenging intellectual question? • Does the thesis statement address the topic given to you? Will it allow you to fully explore and discuss all aspects of the essay prompt? • Is the point I’m making one that would generate discussion, or is it one that would leave people asking, “So what?” • Is my thesis too narrow? Is it a “dead-end” statement? • Is my thesis too vague? Too general? Too broad? Should I focus on some more specific aspect of my topic? • Does my thesis indicate a direction and structure for my paper? • Is the language in my thesis vivid and clear? Is it formulaic, or is it engaging and......

Words: 1249 - Pages: 5

Language

...Austrian philosopher Ludwig Wittgenstein said "The limits of my language are the limits of my world." What are the limits of language and our world? The limits of our language are our knowledge, skills and abilities to use them, and our world - this is our vision, we know how to get along with others. Through language we share information about the world around us. If you do not master the language fully, these limits will prevent us from fully share their views on our environment. Then I will give only partial information, such as allowing our knowledge. Others around us will take the part for the whole and complete, and will conclude that they have betrayed everything we want and that the limits of our world. Boundaries of our world are not only our knowledge of a language, but for different languages. On our planet there are very different to each other languages ​​and cultures. As we meet someone with whom we have a common language, then we can not understand it, nor did he understand us. But you are blind and deaf people, some of whom can not learn spoken language, does this mean that they will never be able to know the world and to convey their opinions? The answer is no, because languages ​​are spoken only: braille letters enable the blind to explore the world, a zhestomimikata helps the deaf to communicate with others. Despite what factors determine the limits of our language, they limit our world from the perspective of others - for them that our world is part of...

Words: 274 - Pages: 2

Comparison of C, C++, and C#

...Jason Latham Comparison of C, C++, and C# IADT Seattle The C family of languages has been a cornerstone in the programming field for years. So exactly what is the C family? It includes the C, C++ and C# (pronounced sharp) languages. Now that we know what they are, what are the differences between the three? Well, that is what will be discussed here. C is a minimalistic programming language because it could be compiled in a straightforward manner by a relatively simple compiler. C offers low-level access to memory via pointers and the ability to access specific hardware addresses. C generates only a few instructions of machine languages for each of its core language elements and does not require extensive run-time support. It can be concluded that C language is suitable for many systems-programming applications that had traditionally been implemented in assembly languages (Gabb, 2012). With its inherent low-level memory access and small run-time support, using C for embedded hardware systems is ideal. Many devices such as robots, machinery, and electronic tools are programmed utilizing its ability to access specific hardware addresses. However, as C is structured oriented programming language and focuses on the procedural programming paradigm, it is relatively hard to control the large-scale program. As C language has high level and machine level mixed programming capacity, it is used in most hardware related applications. It is very suitable for writing programs in......

Words: 1038 - Pages: 5

C++ Languages

...Object-Oriented Programming B.Sc. Programme in Electrical and Computer Engineering C++ Basics Roman Podraza Institute of Computer Science Warsaw University of Technology Project is co-financed by European Union within European Social Fund What Is OOP ? • Object-oriented programming (OOP) is a currently popular and powerful programming technique • Main characteristics of OOP: – Encapsulation: a form of information hiding. – Inheritance: code reusability, refinement of ideas. – Polymorphism: multiple meanings in the context of inheritance. • Origins of C++ 2 A Sample Program in C++ // The first program in C++ #include using namespace std; int main () { cout 0 ) ; else x *= 3; // quite often // a block is used // // // // // e.g. empty statement keyword (optional) statement executed if boolean expression is false 22 Instructions – Multiway if-else statement if (x > 0 && x < 10) x += 10; else if (x >= 10 && x < 20) x += 20; else if (x >= 20 && x < 30) x += 30; else if (x >= 30 && x < 40) x += 40; else x += 100; 23 Instructions if (x > 0) if (y > 2) x -= y; else x += y; if (x > 0) { if (y > 2) x -= y; } else x += y; 24 Instructions • switch statement controlling expression switch ( ch ){ case (’A’): cout name == 0) // a new string (not found in the array) { res->name = new char[strlen(p) + 1]; strcpy (res->name, p); res->val = 0; } return res->val; } 40 References int main(){ const int MAX = 256; char buf[MAX]; while......

Words: 260 - Pages: 2

C Sharp Language Specification

...C# Language Specification Version 4.0 Notice © 1999-2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Visual Basic, Visual C#, and Visual C++ are either registered trademarks or trademarks of Microsoft Corporation in the U.S.A. and/or other countries/regions. Other product and company names mentioned herein may be the trademarks of their respective owners. Table of Contents 1. Introduction 1 1.1 Hello world 1 1.2 Program structure 2 1.3 Types and variables 4 1.4 Expressions 6 1.5 Statements 8 1.6 Classes and objects 12 1.6.1 Members 12 1.6.2 Accessibility 13 1.6.3 Type parameters 13 1.6.4 Base classes 14 1.6.5 Fields 14 1.6.6 Methods 15 1.6.6.1 Parameters 15 1.6.6.2 Method body and local variables 16 1.6.6.3 Static and instance methods 17 1.6.6.4 Virtual, override, and abstract methods 18 1.6.6.5 Method overloading 20 1.6.7 Other function members 21 1.6.7.1 Constructors 22 1.6.7.2 Properties 23 1.6.7.3 Indexers 23 1.6.7.4 Events 24 1.6.7.5 Operators 24 1.6.7.6 Destructors 25 1.7 Structs 25 1.8 Arrays 26 1.9 Interfaces 27 1.10 Enums 29 1.11 Delegates 30 1.12 Attributes 31 2. Lexical structure 33 2.1 Programs 33 2.2 Grammars 33 2.2.1 Grammar notation 33 2.2.2 Lexical grammar 34 2.2.3 Syntactic grammar 34 2.3 Lexical analysis 34 2.3.1 Line terminators 35 2.3.2 Comments 35 2.3.3 White space 37 2.4 Tokens 37 2.4.1 Unicode character escape sequences 37 2.4.2 Identifiers 38 2.4.3......

Words: 47390 - Pages: 190

Language

...Study on the Impact of Information and Communications Technology (ICT) and New Media on Language Learning EACEA 2007/09 ANNEXE II QUANTITATIVE SURVEY Commissioned by: Carried out by: © European Commission STUDY ON THE IMPACT OF INFORMATION AND COMMUNICATIONS TECHNOLOGY (ICT) AND NEW MEDIA ON LANGUAGE LEARNING ANNEXE II: QUANTITATIVE SURVEY 2 STUDY ON THE IMPACT OF INFORMATION AND COMMUNICATIONS TECHNOLOGY (ICT) AND NEW MEDIA ON LANGUAGE LEARNING This is an Annexe to the Final Report of the study regarding the impact of information and communications technology (ICT) and new media on language learning which was commissioned by the Education and Culture Executive Agency (call for tenders EACEA 2007/09) and carried out by Ellinogermaniki Agogi through an international team of experts. Edited and compiled by In conjunction with Reviewers of literature: Field studies: Anne Stevens, The Open University UK Lesley Shield, e-learning consultant Lesley Shield, e-learning consultant (review in the area of CALL) Katerina Zourou, University of Luxembourg (review in other areas) Cyprus Finland France Germany Greece Hungary Spain UK International interviews Data analysis: External advisor: Project Manager: Commissioned by: Pavlos Koulouris, Ellinogermaniki Agogi Peppi Taalas, University of Jyväskylä Ilona Laakkonen, University of Jyväskylä Katerina Zourou, University of Luxembourg Daniela Stai, Ellinogermaniki Agogi Dagmar Schäffer, Ellinogermaniki Agogi Pavlos...

Words: 19071 - Pages: 77

C Language

...comparison Programming Language: A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine, to express algorithms precisely, or as a mode of human communication. Many programming languages have some form of written specification of their syntax (form) and semantics (meaning). Some languages are defined by a specification document. For example, the C programming language is specified by an ISO Standard. Other languages, such as Perl, have a dominant implementation that is used as a reference. Programming language is classified in two ways (1)High level: A high-level programming language is a programming language with strong abstraction from the details of the computer. In comparison to low-level programming languages, it may use natural language elements, be easier to use, or be more portable across platforms. Such languages hide the details of CPU operations such as memory access models and management of scope (2)Low Level: a low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture. The word "low" refers to the small or nonexistent amount of abstraction between the language and machine language; because of this, low-level languages are sometimes described as being "close to the hardware." A low-level language......

Words: 2515 - Pages: 11

Language

...Vernacular Language Jessica Trevino AIU Online University Vernacular Language Vernacular is defined as using a language that is native to a country or province rather than a cultured, foreign or literary language. The Vernacular languages would also be considered as the large family of contemporary romantic language. Vernacular languages would one day be known to use as Spanish, French, Italian, Portuguese and others as well. In the twenty century, Latin was the major language that was used for literature and to be educated. The Latin language was influenced by many others in the native language that included those of Celtic languages, Greek and Etruscan. The Latin languages were consistently developed due to the fact there were significant differences during each period. These differences included those in the literary written language and also due to differences in the spoken language of he educated and those of the less educated population lower class. When it all started the Latin language was the only italic language that belonged to the Indo-European linguistic family and the development of these languages were generated or taken by other tongues, including the language known as Celtic, Etruscan and Greek. The Latin language under went reconstruction, during its evolution stage, between the literary written language which was very different from the way it was spoken and conformed to the educated versus to that of the less educated versus that was most used by...

Words: 443 - Pages: 2

Learn C Programming Language in 24 Hours

...Yourself C in 24 Hours Previous | Table of Contents | Next Hour 1 - Getting Started A journey of a thousand miles is started by taking the first step. —Chinese proverb High thoughts must have high language. —Aristophanes Welcome to Teach Yourself C in 24 Hours. In this first lesson you'll learn the following:     What C is Why you need to learn C The ANSI standard Hardware and software required in order to run the C program What Is C? C is a programming language. The C language was first developed in 1972 by Dennis Ritchie at AT&T Bell Labs. Ritchie called his newly developed language C simply because there was a B programming language already. (As a matter of fact, the B language led to the development of C.) C is a high-level programming language. In fact, C is one of the most popular general-purpose programming languages. In the computer world, the further a programming language is from the computer architecture, the higher the language's level. You can imagine that the lowest-level languages are machine languages that computers understand directly. The high-level programming languages, on the other hand, are closer to our human languages. (See Figure 1.1.) Figure 1.1. The language spectrum. High-level programming languages, including C, have the following advantages:    Readability: Programs are easy to read. Maintainability: Programs are easy to maintain. Portability: Programs are easy to port across different computer platforms. The C......

Words: 73255 - Pages: 294

Language

...Language John Kendrick PSY/360 September 14, 2015 Professor Jackson Language Through sounds, gestures, and symbols humans have learned to communicate with each other. It is a developed system for communicating in a society. Languages will vary from one culture to the next and will take on different forms. Not only are languages spoken, they are expressed through hand gestures and written symbols. Language is a form of communication that allows humans to express emotion, opinions, thoughts, and beliefs (Galotti, 2014). The lexicon is the vocabulary contained within the language. It is the knowledge of the words contained in the language. It is a compilation of all words known, understood, and expressed by the individual. The language is compiled and understood by others contained in the same culture and supports how the language is expressed (Galotti, 2014). One key feature of language is broadcasting the message and then rapid fading of the message. The message will fade and then not heard. The next feature is interchangeability. This is the ability to both receive and send the message. Total feedback is occurs when the speaker can hear his own speech and can monitor the language performance as they go and specialization involves producing the speech through the specialized body parts adapted for this role (Galotti, 2014). The key features of language are phonology, syntax, semantics, and pragmatics. An expression of language occurs when an......

Words: 749 - Pages: 3

C Language

...Solving and 'C' Programming Version: PSC/Handout/1107/1.0 Date: 16-11-07 Cognizant 500 Glen Pointe Center West Teaneck, NJ 07666 Ph: 201-801-0233 www.cognizant.com Problem Solving and C Programming TABLE OF CONTENTS About this Document ....................................................................................................................6 Target Audience ...........................................................................................................................6 Objectives .....................................................................................................................................6 Pre-requisite .................................................................................................................................6 Session 2: Introduction to Problem Solving and Programming Languages ...........................7 Learning Objectives ......................................................................................................................7 Problem Solving Aspect ...............................................................................................................7 Program Development Steps .......................................................................................................8 Introduction to Programming Languages ...................................................................................14 Types and Categories of Programming Languages......

Words: 4320 - Pages: 18

C Language

...Teach Yourself C++ in 21 Days, Second Edition Introduction Week 1 at a Glance: Day 1 Getting Started Day 2 The Parts of a C++ Program Day 3 Variables and Constants Day 4 Expressions and Statements Day 5 Functions Day 6 Basic Classes Day 7 More Program Flow Week 1 in Review Week 2 at a Glance: Day 8 Pointers Day 9 References Day 10 Advanced Functions Day 11 Arrays Day 12 Inheritance Day 13 Polymorphism Day 14 Special Classes and Functions Week 2 in Review Week 3 at a Glance: Day 15 Advanced Inheritance Day 16 Streams Day 17 The Preprocessor Day 18 Object-Oriented Analysis and Design Day 19 Templates Day 20 Exceptions and Error Handling Day 21 Whats Next Week 3 in Review Appendixes A Operator Precedence B C++ Keywords C Binary and Hexadecimal D Answers Index Teach Yourself C++ in 21 Days, Second Edition Dedication This book is dedicated to the living memory of David Levine. Acknowledgments A second edition is a second chance to acknowledge and to thank those folks without whose support and help this book literally would have been impossible. First among them are Stacey, Robin, and Rachel Liberty. I must also thank everyone associated with my books, both at Sams and at Wrox press, for being professionals of the highest quality. The editors at Sams did a fantastic job, and I must especially acknowledge and thank Fran Hatton, Mary Ann Abramson, Greg Guntle, and Chris Denny. I have taught an online course based on this book for a couple years, and many folks......

Words: 4907 - Pages: 20