Professional Documents
Culture Documents
INTRODUCTION TO
C++
PREPARED BY MR. JOHN PATRICK S. PAULINO
OBJECTIVES
01 02 03
Discuss the basics Apply the general Develop a program
of C++ structure of C++ using C++
programming programming programming
language. language. language.
Writing a
C++ Program
Properly written C++ programs have a
particular structure. The syntax must be
correct, or the compiler will generate error
messages and not produce executable
machine language.
Syntax
The set of rules that defines the
combinations of symbols that are
considered to be correctly structured
statements or expressions in that language.
TRY THIS!
Input the codes on the compiler and execute to see the output.
C++ BASIC PROGRAM STRUCTURE
#include <iostream>
➢ This line is a preprocessing directive.
➢ All preprocessing directives within C++ source code begin with a # symbol.
➢ It allows to use the standard input (cin) and output (cout) statements.
int main () {
➢ The starting point of the program execution.
➢ The opening curly brace { at the end of the line marks the
beginning of the body of a function. The body of a function
contains the statements the function is to execute.
C++ BASIC PROGRAM STRUCTURE
cout << “Hello, World!”;
➢ This statement directs the executing program to print the message
Hello, World! on the computer screen.
➢ All statements in C++ end with a semicolon (;).
return 0;
➢ This will terminate the int main() function and causes it to return
the value 0 to the calling process.
}
➢ Closing curly brace closes the body of the main function.
VARIABLE
- A name the programmer uses
to refer to the computer
storage locations. Used to hold
values.
Expression
● An arrangement of identifier, literals, and operators that can be
evaluated to compute a value of a given type.
Evaluate
● To compute a new value by performing a specified set of operations
on the given values.
Identifier
● It refers to a name composed of a sequence of letters, digits, and
underscores.
● Variable names in C++ can
range from 1 to 255
characters.
● All variable names must
begin with a letter of the
RULES IN alphabet or an underscore (_).
DECLARING A ● After the first initial letter,
variable names can also
VARIABLE IN C++ contain letters and numbers.
● Variable names are case
sensitive.
● No spaces or special
characters are allowed.
● You cannot use a C++
keyword/reserved word as a
variable name.
KEYWORDS IN C++
Keywords in C++ are also known as reserved words, which means they
must be used only for their specified purpose.
STREAM DESCRIPTION
OPERATORS MEANING
== is equal to
!= is not equal to
LOGICAL OPERATORS
Used to combine two or more conditions/constraints or to complement
the evaluation of the original condition in consideration. The result is a
Boolean value either TRUE or FALSE.
OPERATORS DESCRIPTION
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
QUESTION?