Curso C++: Clase 07 - Arreglos/Arrays
Curso C++: Clase 07
Contenido:
- Conceptos basicos
- Estructura básica
- Ejemplo007
Mi blog: https://eleshare.blogspot.com/ by Jose Luis Quijada - Elezero
Codigo:
#include <stdio.h> #include <stdlib.h> #include <iostream> using namespace std; int main() { //position 0 1 2 3 4 char vocales[5] = {'a', 'b', 'c', 'd', 'e'}; //position 0 1 2 3 int numeros[] = {1, 2, 3, 4}; float cuentas[5]; cuentas[0] = 111.11; cuentas[1] = 222.2; cuentas[2] = 333.3; cuentas[3] = 4.4; cout << "Longitud del arreglo vocales: " << (sizeof(vocales)/sizeof(*vocales)) << endl; cout << "Longitud del arreglo numeros: " << (sizeof(numeros)/sizeof(*numeros)) << endl; cout << "Longitud del arreglo cuentas: " << (sizeof(cuentas)/sizeof(*cuentas)) << endl; cout << "Arreglo vocales: "; for(int i = 0; i<(sizeof(vocales)/sizeof(*vocales)); i++){ cout << vocales[i] << " "; } cout << "\nArreglo numeros: "; for(int i = 0; i<(sizeof(numeros)/sizeof(*numeros)); i++){ cout << numeros[i] << " "; } cout << "\nArreglo cuentas: "; for(int i = 0; i<(sizeof(cuentas)/sizeof(*cuentas)); i++){ cout << cuentas[i] << " "; } cout << endl; return 0; }
Comments
Post a Comment