Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Arreglos:
- //Los arreglos estaticos solo aceptan valores literales
- int suma ()
- {
- int uno = 5;
- int dos = 6;
- int resultado = uno + dos;
- cout << resultado << endl;
- return resultado;
- }
- int main()
- {
- int array[5];
- char word[3];
- //Los for cuentan con tres partes: definicion, condicion e iteracion
- //Llenar un arreglo, forma 1:
- for (int i = 0; i < 5; i++)
- {
- array[i] = i;
- cout << array[i] << endl;
- }
- //forma 2:
- word[0] = 'a';
- word[1] = 's';
- word[2] = '\0';
- cout << word << endl;
- //Esto combierte a nuestro arreglo en un string
- //forma 3:
- float flotantes[4] = { 1.0f,1.1f,1.2f,1.3f };
- cout << flotantes[0,3] << endl;
- //Segundo ejemplo de asignacion automatica
- short automatic[45];
- for (int i = 0; i < 45; ++i)
- {
- automatic[i] = i + 3;
- }
- cout << automatic[0,44] << endl;
- cin.get();
- suma ();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement