Please enable JavaScript.
Coggle requires JavaScript to display documents.
Chapter 2: PROGRAM ELEMENTS (Declare Variable (3-You can define a variable…
Chapter 2: PROGRAM ELEMENTS
Main Function
i) A C++ program is simply a collection of function blocks.
ii) void main() {...}defines the code that should execute first when the program starts up. The curly braces represent grouping of multiple commands into a block.
Preprocessor
#include < filename.h>
*#include tells the computer to copy, or include the given file name into C++ program.
#include tells the preprocessor to dump in the contents of another file
2 Types of comment
/
Multiline Comment
/
/
This program is for you to understand how to write multiline comments using multiline comment symbol
/
// Double Forward Flash
//This program is for lab 1
Declare Variable
3-You can define a variable anyplace within a program as long as it is defined before it is used.
2-When you defined a variable, the compiler reserves a location inside the computer memory for the variable value.
1-Before you can use a variable in C++, it must be defined.
CONSTANT
a. Constant refers to fixed values that cannot be changed by the program.
b. It is a good programming practice to give constant name is capital letter to differential between VariableName and CONSTANTNAME.
RULES OF NAMING VARIABLE & IDENTIFIER
Case-Sensitive
start with the Letter or Underscore
No space or puntuation
Cannot use KEYWORD
Length
1.INTEGER
2.Floating-point
3.Character
Mathematic Operator
Add (+)
Subtract ( -)
Multiply (*)
Divide (/)
Modulus (%)
STEPS
Data Type in C++