The Basics of a C++ Program

Basic Elements of C++

The Basics of a C++ Program

A C++ program is a collection of one or more subprograms (functions)
Function
Collection of statements
Statements accomplish a task
Every C++ program has a function called main

Example Program
#include
using namespace std;
int main()
{
cout<<« Welcome to C++ Programming »<<endl;
return 0;
}

The Basics of a C++ Program
Programming language
a set of rules, symbols, special words
Rules
syntax – specifies legal instructions
Symbols
special symbols ( + – * ! … )
Word symbols
reserved words
(int, float, double, char …)

Identifiers
Rules for identifiers
must begin with letter or the underscore _
followed by any combination of numerals or letters
recommend meaningful identifiers
Evaluate the following
ElectricCharge
23Skidoo
snarFbLat

Arithmetic Operators and Operator Precedence
Common operators for calculations+ – * / %
Precedence same as in algebraic usage
Inside parentheses done first
Next * / % from left to right
Then + and – from left to right

Cours gratuitTélécharger le cours complet

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.