Essays.club - Ensayos gratis, notas de cursos, notas de libros, tareas, monografías y trabajos de investigación
Buscar

-En el ejemplo pasado, la funcionalidad es cuestionable, pues tenemos que escribir severas líneas de código, compilarlas y después ejecutarlas para tener el programa. En este caso solo para obtener las palabras "Hola mundo"

Enviado por   •  17 de Mayo de 2018  •  843 Palabras (4 Páginas)  •  505 Visitas

Página 1 de 4

...

-Tipos de información fundamentales

-Los valores de las variables son almacenados en alguna localidad de la memoria de la computadora, no especificada, como 1's y 0's

-El programa no necesita saber específicamente donde están almacenadas las variables, solo basta con "mandarlas a llamar", aunque no es lo mismo que almacenemos un número, una cadena de números o incluso una palabra, a final de cuentas igual son 1's y 0's. Por este motivo hay diferentes tipos de variables

Character types: They can represent a single character, such as 'A' or '$'. The most basic type is char, which is a one-byte character. Other types are also provided for wider characters.

Numerical integer types: They can store a whole number value, such as 7 or 1024. They exist in a variety of sizes, and can either be signed or unsigned, depending on whether they support negative values or not.

Floating-point types: They can represent real values, such as 3.14 or 0.01, with different levels of precision, depending on which of the three floating-point types is used.

Boolean type: The boolean type, known in C++ as bool, can only represent one of two states, true or false.

[pic 1]

-Therefore, the type is not required (and in many cases is not) exactly this minimum size.

Type sizes above are expressed in bits; the more bits a type has, the more distinct values it can represent, but at the same time, also consumes more space in memory

C++ is a strongly-typed language, and requires every variable to be declared with its type before its first use. This informs the compiler the size to reserve in memory for the variable and how to interpret its value. The syntax to declare a new variable in C++ is straightforward: we simply write the type followed by the variable name (i.e., its identifier). For example:

int a;

float mynumber;

int a, b, c;

int a;

int b;

int c;

-When the variables in the example above are declared, they have an undetermined value until they are assigned a value for the first time. But it is possible for a variable to have a specific value from the moment it is declared. This is called the initialization of the variable.

-In C++, there are three ways to initialize variables. They are all equivalent and are reminiscent of the evolution of the language over the years:

int x = 0;

int x (0);

int x {0};

...

Descargar como  txt (5.2 Kb)   pdf (47.3 Kb)   docx (13.1 Kb)  
Leer 3 páginas más »
Disponible sólo en Essays.club