

C++ Variables
Presentation
•
Computers
•
University
•
Practice Problem
•
Hard
Kittisay SENGTHONG
Used 46+ times
FREE Resource
13 Slides • 13 Questions
1
C++ Variables
ຕົວປ່ຽນຂອງພາສາ C++

2
C++ Variables
Variables are containers for storing data values.
In C++, there are different types of variables (defined with different keywords), for example:
3
Multiple Choice
ຕົວປ່ຽນແມ່ນຫຍັງ
ຂໍ້ມູນ
ບ່ອນຈັດເກັບຂໍ້ມູນ
ປະເພດຂໍ້ມູນ
ຈຳນວນ
4
C++ Variables
int - stores integers (whole numbers), without decimals, such as 123 or -123
double - stores floating point numbers, with decimals, such as 19.99 or -19.99
char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
string - stores text, such as "Hello World". String values are surrounded by double quotes
bool - stores values with two states: true or false
5
Multiple Choice
ຂໍ້ໃດຕໍ່ໄປນີ້ແມ່ນປະເພດຂອງຕົວປ່ຽນຂອງພາສາ C++
data
type
string
6
Declaring (Creating) Variables
To create a variable, you must specify the type and assign it a value:
7
Fill in the Blanks
ຕົວປ່ຽນພາສາອັງກິດຂຽນແບບໃດ
Type answer...
8
Fill in the Blanks
ຈົ່ງຂຽນຕົວປ່ຽນທີ່ຕົວເອງຮູ້ຈັກມາ 1 ຕົວປ່ຽນ
Type answer...
9
Syntax variable C++
Where type is one of C++ types (such as int), and variable is the name of the variable (such as x or myName). The equal sign is used to assign values to the variable.
Create a variable called myNum of type int and assign it the value 15:
10
Multiple Choice
ຂໍ້ໃດຕໍ່ໄປນີ້ແມ່ນການສ້າງຕົວປ່ຽນທີ່ຖືກຕ້ອງ
int a=50;
int a=7
int a="a"
int a="a";
11
Syntax Variables
You can also declare a variable without assigning the value, and assign the value later:
12
Fill in the Blanks
ໃຫ້ສ້າງຕົວປ່ຽນ ປະເພດຕົວເລກ ແລະ ຕັ້ງຊື່ວ່າ Mydata ໂດຍບໍ່ຕ້ອງກຳນົດຄ່າໃຫ້ກັບຕົວປ່ຽນ
Type answer...
13
Syntax Variables
Note that if you assign a new value to an existing variable, it will overwrite the previous value:
14
Fill in the Blanks
ຈົ່ງຂຽນຄຳສັ່ງກຳນົດຂໍ້ມູນໃຫ້ກັບຕົວປ່ຽນ int a=5; ໂດຍກຳນົດຄ່າໃຫ້ກັບຕົວປ່ຽນ ຈາກ 5 ໃຫ້ປ່ຽນເປັນ 10
Type answer...
15
Other Types
int myNum = 5; // Integer (whole number without decimals)
double myFloatNum = 5.99; // Floating point number
char myLetter = 'D'; // Character
string myText = "Hello"; // String (text)
bool myBoolean = true; // Boolean (true or false)
16
Multiple Choice
ຂໍ້ໃດຕໍ່ໄປນີ້ແມ່ນການກຳນົດ ຄ່າໃຫ້ກັບຕົວປ່ຽນ ທີ່ ບໍ່ຖືຕ້ອງ
int a=50;
double b=55.6;
bool a=50;
string a="love";
17
C++ Declare Multiple Variables
To declare more than one variable of the same type ( , ) use a comma-separated list:
int x = 5, y = 6, z = 50;
cout << x + y + z;
18
Fill in the Blanks
ຈົ່ງສ້າງຕົວປ່ຽນປະເພດ string ຂື້ນມາ 3 ຕົວປ່ຽນຄື: name,surname,nickname
Type answer...
19
C++ Identifiers
All C++ variables must be identified with unique names.
These unique names are called identifiers.
Identifiers can be short names (like x and y) or more descriptive names (age, sum, totalVolume).
Note: It is recommended to use descriptive names in order to create understandable and maintainable code:
20
Multiple Select
ຂໍ້ໃດຕໍ່ໄປນີ້ເປັນການ ຕັ້ງຊື່ຕົວປ່ຽນທີ່ ຖືກຕ້ອງ
name surname
int
reSult
total
21
C++ Identifiers
how to create Variables is very good
22
C++ Identifiers
Names can contain letters, digits and underscores
Names must begin with a letter or an underscore (_)
Names are case sensitive (myVar and myvar are different variables)
Names cannot contain whitespaces or special characters like !, #, %, etc.
Reserved words (like C++ keywords, such as int) cannot be used as names
23
Multiple Select
ຂໍ້ໃດຕໍ່ໄປນີ້ເປັນການ ຕັ້ງຊື່ຕົວປ່ຽນທີ່ ບໍ່ຖືກຕ້ອງ
name surname
_year
#data
sum
24
C++ Constants
When you do not want others (or yourself) to override existing variable values, use the const keyword (this will declare the variable as "constant", which means unchangeable and read-only):
25
Fill in the Blanks
ໃຫ້ຂຽນຄຳສັ່ງ ກຳນົດຄ່າຄົງທີ່ ໃຫ້ກັບຕົວປ່ຽນ
Type answer...
26
Poll
ຫົວຂໍ້ໃດຕໍ່ໄປນີ້ ຍັງບໍ່ທັນເຂົ້າໃຈດີ ຫຼື ທີ່ຄິດວ່າຍາກ
C++ Variables
C++ Declare Multiple Variables
C++ Identifiers
C++ Constants
C++ Variables
ຕົວປ່ຽນຂອງພາສາ C++

Show answer
Auto Play
Slide 1 / 26
SLIDE
Similar Resources on Wayground
16 questions
Php basic
Presentation
•
University
21 questions
Introducción a las ondas BAIN100
Presentation
•
University
20 questions
Types of Random Variables
Presentation
•
University
19 questions
Urban Leadership - Managing People
Presentation
•
University
20 questions
H-L6U6: Articles
Presentation
•
University
23 questions
Apuntador de Apuntadores
Presentation
•
University
18 questions
Python- Function (Parameter, Argument and Return)
Presentation
•
12th Grade
20 questions
Basics of Marketing
Presentation
•
University
Popular Resources on Wayground
10 questions
Safety Day 2026 – Student Review
Quiz
•
9th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
16 questions
Subject & Predicate
Quiz
•
5th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
Map Skills
Quiz
•
3rd Grade
22 questions
Continents and Oceans
Quiz
•
5th Grade
15 questions
Rounding Decimals
Quiz
•
5th Grade
Discover more resources for Computers
20 questions
Disney Trivia
Quiz
•
University
10 questions
Spanish Greetings and Goodbyes!
Presentation
•
6th Grade - University
20 questions
Physical or Chemical Change/Phases
Quiz
•
8th Grade - University
39 questions
Unit 7 Key Terms
Quiz
•
11th Grade - University
25 questions
SER and Subject Pronouns
Quiz
•
8th Grade - University
38 questions
Unit 6 Key Terms
Quiz
•
11th Grade - University
19 questions
Key Concepts in Buddhism
Quiz
•
University
0 questions
Cell Domain Basic Review (Biology)
Quiz
•
University