#include <iostream> |
Please input 5 numbers. Seperate the numbers by spaces: |
score[0] |
score[1] |
score[2] |
score[3] |
score[4] |
| 92.25 | 33 | 45.75 | 88.8 | 77.77 |
double score[5] declares an array of 5 doubles names
scoresscore[i] is the i-th element. | Declare an array Type arrayName[size]; size should be a number or a const variable. It shouldn't be other type of variables. |
int year[50];int is called the base type of the array, 50
is the size. year is the name. double taxRate, income[99];The order doesn't matter.
#include <iostream> |
const int NUM_OF_STUDENTS = 100;
#include <iostream> |
score[0],score[1],score[2],score[3],score[4]
represent the first, second, third, forth and fifth element in the
array scorescore[i] as variables. i.e. you can use
it in assignments, arithmetic expression etc etcscore[i],
or income[n+1].
for(i = 0; i < NUM_OF_STUDENTS; i++) {
|
double temperature[24]; // 24 is array sizetemperaturetemperature[0], temperature[1] … temperature[23]temperature[24] = 5;
#include<iostream> |
1245120 |
int children[3] = {2, 12, 1};
|
int children[3]; |
int b[] = {5, 12, 11};
|
int b[3] = {5, 12, 11};
|
#include<iostream> |
| 1 3 5 0 0 |