Tag Archives: #f0f0f0

Fundamental Data Type

FUNDAMENTAL DATA TYPE

The values of variables are stored somewhere in an unspecified location in the computer memory as zeros and ones. Our program does not need to know the exact location where a variable is stored; it can simply refer to it by its name. What the program needs to be aware of is the kind of data stored in the variable. It’s not the same to store a simple integer as it is to store a letter or a large floating-point number; even though they are all represented using zeros and ones, they are not interpreted in the same way, and in many cases, they don’t occupy the same amount of memory.


Fundamental data types are basic types implemented directly by the language that represent the basic storage units supported natively by most systems. They can mainly be classified into:

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


Here is the complete list of fundamental types in C++:

Character types char Exactly one byte in size. At least 8 bits.
char16_t Not smaller than char. At least 16 bits.
char32_t Not smaller than char16_t. At least 32 bits.
wchar_t Can represent the largest supported character set.
Integer types (signed) signed char Same size as char. At least 8 bits.
signed short int Not smaller than char. At least 16 bits.
signed int Not smaller than short. At least 16 bits.
signed long int Not smaller than int. At least 32 bits.
signed long long int Not smaller than long. At least 64 bits.
Integer types (unsigned) unsigned char (same size as their signed counterparts)
unsigned short int
unsigned int
unsigned long int
unsigned long long int
Floating-point types float  
double Precision not less than float
long double Precision not less than double
Boolean type bool  
Void type void no storage
Null pointer decltype(nullptr)  


* The names of certain integer types can be abbreviated without their signed and int components – only the part not in italics is required to identify the type, the part in italics is optional. I.e., signed short int can be abbreviated assigned shortshort int, or simply short; they all identify the same fundamental type.

Recuperado de: http://www.cplusplus.com/doc/tutorial/variables/

 Para aquellos atascados que sólo quieren saber lo que necesitan, hay 5 tipos de datos para las variables. Son string, int, float, long y bool. 

El tipo string es meramente para texto.

El tipo int es intiger que es para números enteros.

El tipo float es un número que admite números con puntos decimales.

El tipo long es para números de gran valor.

El tipo bool es solamente para dar un valor de true o false.

Para funciones hay un valor llamado voit que es para que imprima un valor sin necesidad de poner un cout. Tener mucho cuidado con las funciones a utilizar sobre todo en las funciones.

1017

09

 

Mastery 10

Basic output (printing) and inpur (text based) in C++

The standard library defines a handful of stream objects that can be used to access what are considered the standard sources and destinations of characters by the environment where the program runs:

stream description
cin standard input stream
cout standard output stream
cerr standard error (output) stream
clog standard logging (output) stream

Standard output (cout)

On most program environments, the standard output by default is the screen, and the C++ stream object defined to access it is cout.

For formatted output operations, cout is used together with the insertion operator, which is written as << (i.e., two “less than” signs).

cout << "Output sentence"; // prints Output sentence on screen
cout << 120;               // prints number 120 on screen
cout << x;                 // prints the value of x on screen  

Standard input (cin)

In most program environments, the standard input by default is the keyboard, and the C++ stream object defined to access it is cin.

For formatted input operations, cin is used together with the extraction operator, which is written as >> (i.e., two "greater than" signs). This operator is then followed by the variable where the extracted data is stored. For example:

int age;
cin >> age;

#TC1017 #Mastery13

C Library

The elements of the C language library are also included as a subset of the C++ Standard library. These cover many aspects, from general utility functions and macros to input/output functions and dynamic memory management functions:

#TC1017 #Mastery13

#TC1017 #Mastery10

The standard input and output:

stream description
cin standard input stream
cout standard output stream
cerr standard error (output) stream
clog standard logging (output) stream

Here is a little example:

<iostream>
using namespace std;

int main()

{

chart a;
cout << “Please write a letter:”;
cin >> x;
cout << “This is your letter:” << x << endl;

return 0;

}

Mastery 09 – Basic types and their use in C++

Hey there! in this post we are going to talk about fundamental types in C++.

Any value we use in our code, requieres a space in the computers memory. What the computer need to know to run the program correctly is how much space need the value and how to read it.

Here is a table with the fundamental types used in C++. The most common used are char, float, (signed) int double (float), bool and void.

Check it, and I hope it helps you.

 

Group Type names* Notes on size / precision
Character types char Exactly one byte in size. At least 8 bits.
char16_t Not smaller than char. At least 16 bits.
char32_t Not smaller than char16_t. At least 32 bits.
wchar_t Can represent the largest supported character set.
Integer types (signed) signed char Same size as char. At least 8 bits.
signed short int Not smaller than char. At least 16 bits.
signed int Not smaller than short. At least 16 bits.
signed long int Not smaller than int. At least 32 bits.
signed long long int Not smaller than long. At least 64 bits.
Integer types (unsigned) unsigned char (same size as their signed counterparts)
unsigned short int
unsigned int
unsigned long int
unsigned long long int
Floating-point types float  
double Precision not less than float
long double Precision not less than double
Boolean type bool  
Void type void no storage
Null pointer decltype(nullptr)