Array is a variable that holds a bunch of values in it.(multiple values saved in a single variable)
Simple! and Useful!
#include <iostream>
#include <cmath>
int main()
{
using namespace std;
/*1. type what kind of the value of the array
2. name
3. square brackets--> how many values it can store
*/
int ages[3]; //3 only
ages[0] = 21;
ages[1] = 19;
ages[2] = 9;
/*
same as====> int ages[3] = {21,19,9};
: faster, easier, and quicker
*/
//perform as if it is a variable
cout<<ages[1] + ages[0]<<endl; //40
system("pause");
return 0;
}
'Computer General > C++ development from the beginning' 카테고리의 다른 글
| Address Operator & Pointer (0) | 2014.12.12 |
|---|---|
| Beginning Loop (0) | 2014.12.12 |
| User Defined Functions (0) | 2014.12.12 |
| Beginning Math Functions (0) | 2014.12.12 |
| How to start C++ for beginners (0) | 2014.12.10 |