BASIC PROGRAM ELEMENTS / BASIC C++ PROGRAM (APPLY OPERATORS AND EXPRESSION) πŸ’₯

VARIABLE AND CONSTANT ✏

⭐ Give the computer the name or address of a memory location where the data to be save.

⭐ Tell the computer , the data type you want to save.

⭐ Computer will reserves a location inside the computer memory for the computer memory for the variable value.

DECLARE VARIABLE πŸ–Š

⭐ Use a variable in C++ , it must be defined.

⭐ When define the variable , the compiler reserves a location inside the computer memory for the variable value.

⭐ Can define a variable anyplace within a program as long as it is defined before it is used.

βœ’ DEFINE CHARACTER

⭐ 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.

🎺 DEFINE STRING


🚩 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.

βœ… UNLIMITED STRING


⭐ The system will reserve a memory place name which is character data type but group in string and with a enough space size.

πŸŽ‰ CONSTANT

⭐ Constant refers to fixed values that cannot be changed by the program.

⭐ It is a good programming practice to give constant name is CAPITAL LETTER to differentiate between variable name and constant name.

🚩 STRING CONSTANT

⭐ Use some information like our name , our address or our phone number , as a example for printing purpose.

🍾 COUT

⭐ FORMAT


βœ… cout<<item1<<item2<<item3;

⭐ Getting out fixed numeric information.

⭐ Getting out fixed character information.

⭐ Getting out variable information.

⭐ Defination


βœ… cout is the standard output stream OBJECT.

✏ CIN

🚩 FORMAT


⭐ cin>>item1

🚩 Header File Needed


⭐ <iostream>

🚩 Rules


⭐ only one character is read at a time.

πŸ’₯ IDENTIFIER SCOPE

🏴 LOCAL

⭐ Local variables are declared inside a function and can be used only inside that function.

⭐ It is possible to have local variables with the same name in different function.

⭐ 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.

🏴 GLOBAL

⭐ Global variables are declared outside any function , and they can be accessed on any function in the program.

⭐ 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.

πŸ’₯ ARITHMETIC OPERATION

β›” Picture1

β›” DIVISION (/)

⭐ Only the divide operator need special attention.

⭐ When divide two integer number , you may get a floating-point answer.

⭐ Warning of possible losing of data.

β›” MODULUS OPERATOR (%)

⭐ Simply generate the remainder that when you divide 2 integers.

⭐ The modulus operator can only used for integers and will generate a compiler error if you attempt to apply it to floating values.

🚩 PRECEDENCE OPERATOR

⭐ All operator within parentheses are performed first ()

⭐ Parentheses within parenthesesn( ( ) ) inner parentheses will be performed first , from inside out.

⭐ The *,/,% are performed first , from left to right.

⭐ The +,- are performed last , from left to right.

⚠ LOGICAL OPERATION

Picture5

⚠ BOOLEAN OPERATION / RELATIONAL OPERATION

Picture3