Stats: 3,191,144 members, 7,943,102 topics. Date: Sunday, 08 September 2024 at 05:41 AM |
Nairaland Forum / Science/Technology / Programming / Deep Dive Into Variables Series(ii) (293 Views)
0x01. C - Variables, If, Else, While ALX Task / Deep Dive Into Variables Series / Variables In Programming (2) (3) (4)
(1) (Reply)
Deep Dive Into Variables Series(ii) by logicDcoder(m): 5:07pm On Aug 04, 2022 |
THE SIZE OF A VARIABLE The size of a variable is the number of memory spaces it can accept, determined by the kind of data it can store. So when you declare a variable of the type float, your computer automatically allocates memory or a cell of the size 4 bytes, extending to other data types. SIZES OF DIFFERENT KINDS OF VARIABLES INTEGER VARIABLES: Short Integer - 2 bytes - 16 bits. Integer - 4 bytes - 32 bits. FLOATING-POINT VARIABLES: Float - 4 bytes - 32bits. Double - 8 bytes - 64bits. Long Double - 10 bytes - 80bits. NON NUMERICAL VARIABLE: Character - 1 byte - 8bits. Object - Determined by the number of attributes in the class of an object. String - Determined by the number of characters in the string. STATIC VERSUS DYNAMIC In statically written languages, we can stipulate the kind of data or values our variables can pack (Declaration of variables) as opposed to dynamically written languages in which the type of data a variable can accept is determined by the initial value it takes. We do not declare variables in some dynamically written languages. WHAT HAPPENS WHEN I DECLARE A VARIABLE? In statically written programming languages (Java, C, C++, C#, etc), when a variable is declared, a cell is automatically allocated for the variable. In most cases (language-dependent), the allocated cell or space may contain a garbage value; this value is a result of other programs utilizing that particular memory cell or space and releasing it when terminated without proper deallocation. And this is where INITIALIZATION comes in. INITIALIZATION is the act of assigning a variable its initial value. We can use INITIALIZATION to reset the values or bits in the memory cell.
|
(1) (Reply)
How To Promote Your Fiverr Gigs And Make More Money As Freelancer / Website Development / One Site/tool Any Tech Guru Wouldn't Stop Using
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 9 |