Please enable JavaScript.
Coggle requires JavaScript to display documents.
BASIC PROGRAM ELEMENTS / BASIC C++ PROGRAM (APPLY OPERATORS AND…
BASIC PROGRAM ELEMENTS / BASIC C++ PROGRAM (APPLY OPERATORS AND EXPRESSION) :explode:
VARIABLE AND CONSTANT :pencil2:
:star: Give the computer the name or address of a memory location where the data to be save.
:star: Tell the computer , the data type you want to save.
:star: Computer will reserves a location inside the computer memory for the computer memory for the variable value.
DECLARE VARIABLE :pen:
:star: Use a variable in C++ , it must be defined.
:star: When define the variable , the compiler reserves a location inside the computer memory for the variable value.
:star: Can define a variable anyplace within a program as long as it is defined before it is used.
:fountain_pen: DEFINE CHARACTER
:star: The system will reserve a memory place named which is character data type and with a size of 1 bit and another 1 bit will be automatically reserve by the system for the terminator "\0" which means end of data.
:trumpet: DEFINE STRING
:red_flag: The system will reserve a memory place named name which is character data type but group in string and with a size of 4 bit as defined.
:check: UNLIMITED STRING
:star: The system will reserve a memory place name which is character data type but group in string and with a enough space size.
:tada: CONSTANT
:star: Constant refers to fixed values that cannot be changed by the program.
:star: It is a good programming practice to give constant name is CAPITAL LETTER to differentiate between variable name and constant name.
:red_flag: STRING CONSTANT
:star: Use some information like our name , our address or our phone number , as a example for printing purpose.
:champagne: COUT
:star: FORMAT
:check: cout<<item1<<item2<<item3;
:star: Getting out fixed numeric information.
:star: Getting out fixed character information.
:star: Getting out variable information.
:star: Defination
:check: cout is the standard output stream OBJECT.
:pencil2: CIN
:red_flag: FORMAT
:star: cin>>item1
:red_flag: Header File Needed
:star: <iostream>
:red_flag: Rules
:star: only one character is read at a time.
:explode: IDENTIFIER SCOPE
:black_flag: LOCAL
:star: Local variables are declared inside a function and can be used only inside that function.
:star: It is possible to have local variables with the same name in different function.
:star: Even the name is the same , they are not the same . It's like two people with the same name. Even the name is the same , the persons are not.
:black_flag: GLOBAL
:star: Global variables are declared outside any function , and they can be accessed on any function in the program.
:star: The scope of a variables refers to where is a variables visible or accesible. If a person asks what is the scope of a variable , she's asking whether it is local or global.
:explode: ARITHMETIC OPERATION
:no_entry:
:no_entry: DIVISION (/)
:star: Only the divide operator need special attention.
:star: When divide two integer number , you may get a floating-point answer.
:star: Warning of possible losing of data.
:no_entry: MODULUS OPERATOR (%)
:star: Simply generate the remainder that when you divide 2 integers.
:star: The modulus operator can only used for integers and will generate a compiler error if you attempt to apply it to floating values.
:red_flag: PRECEDENCE OPERATOR
:star: All operator within parentheses are performed first ()
:star: Parentheses within parenthesesn( ( ) ) inner parentheses will be performed first , from inside out.
:star: The *,/,% are performed first , from left to right.
:star: The +,- are performed last , from left to right.
:warning: LOGICAL OPERATION
:warning: BOOLEAN OPERATION / RELATIONAL OPERATION