delphinhawe
Erfahrenes Mitglied
Code:
# include <stdio.h>
void main(void)
{
int x[10],y;
for(y=0;y<10;y++)
{
printf("%i \n",x[y]=y);
}
}
Hallo Programmierer,
bisher habe ich das Variablenfeld ,, int x [10] , y; “ geübt und im C-Buch gut verstanden.
Es wird 10 mal ausgegeben, so dass ich nicht 10 mal Datentyp, Name und Inhalt schreiben muss.
Die Ausgabe sieht wie folgt aus: 0 1 2 3 4 5 6 7 8 9.
Nun steht im Buch ein zweites Beispiel wie folgt: ,,int x [6] = {5, -89, 3, 63, 0, -17}; " ,
zu lesen im Buch aber nicht die 2.Quellcode-Beispiel und keine Erklärung.
Wenn ich das 2.Variablenfeld betrachte, dann denke ich , dass das 2.Variablenfeld 6 mal ausgegeben wird.
Die Ausgabe sieht dann so aus: 5 –89 3 63 0 –17 anstatt 0 1 2 3 4 5!
Nun klappt mein 2. Quellprogramm nicht so ganz.
Ich würde mich freuen, wenn ihr mein Quellprogramm nachbessert! Danke schon mal im Voraus
![Wink ;) ;)](https://cdn.jsdelivr.net/joypixels/assets/8.0/png/unicode/64/1f609.png)
Gruß delphinhawe
Code:
# include <stdio.h>
void main(void)
{
int x [6] = {5, -89, 3, 63, 0, -17};
int y;
for(y=0;y<10;y++) //?
{
printf("%i \n",x[y]=y); //?
}
}