- 1
is this possible ?
int f [4]; cin>>f; is this array can hold 5 data but the data is that i will enter is 1.. i will use this code for airline reservation ticket
4 Antworten
+ 3
When you declare your array, the number in the brackets is the number of elements in that array. The index starts at 0 and goes up to the number of elements minus 1. For your example, you declared an array with four elements. The indexing for that array is 0 to 3, which is four numbers: 0, 1, 2, 3. As Petr said, you have to fill the entire array with a for loop and same for displaying it.
+ 2
It is not possible You can use this:
for(int i=0;i<4,i++) cin>>f[i];
Btw it hold only 4 values, with indexes form 0 to 3
0
but my lecture says that array start with 0
0
thank you for that idea .. i learn from it