📖 Samacheer Kalvi · 11th TN - English Medium · Computer Science · Page 138question

Data Types, Variables and Expressions · Part 8

Chapter 3: 4 · Computer Science

that is specified along with the variable name. For example, if you declare a variable as int type, in Dev C++, the compiler allocates bytes of memory. Thus, every variable should be declared along with the type of value to be stored. Declaration of more than one variable: More than one variable of the same type can be declared as a single statement using a comma separating the individual variables.

Syntax: <data type> <var1>, <var2>, <var3> …… < >; Example: int num1, num2, sum; In the above statement, there are three variables declared as int type. Which means, in num1, num2 and sum , you can store only integer values. For the above declaration, the C++ compiler allocates bytes of memory (i.e. memory boxes) for each variable.

0x125e 0x126e 0x127e 0x128e 0x129e 0x130e 0x131e 0x132e 0x133e 0x134e L - value (Memory Address int num1, num2, sum; num2 Variable names num1 Figure . Memory allocation of int type variables Chapter Page - - If you declare a variable without any initial value, the memory space allocated to that variable will be occupied with some unknown value. These unknown values are called as “Junk” or “Garbage” values. #include <iostream> using namespace std; int main() int num1, num2, sum; cout << num1 << endl; cout << num2 << endl; cout << num1 + num2; In the above program, some unknown values will be occupied in memory that is allocated for the variables num1 and num2 and the statement c out << num1 + num2; will display the sum of those unknown junk values.

. . Initialization of variables Assigning an initial value to a variable during its declaration is called as “Initialization”. Examples: int num = ; float pi = .

; double price = . ; Here, the variables num, pi, and price have been initialized during the declaration. These initial values can be later changed during the program execution. #include <iostream> using namespace std; int main() float pi = .

, radius, height, CSA; cout << "\n Curved Surface Area of a cylinder"; cout << "\n Enter Radius

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →