c++ - Int Array[ ] not printing good. -


here code:

#include <stdio.h> void main()    {    int indeks, a[11], j, rezultat[50];    int n = 0;     printf("unesite elemenate niza\n");     while (n < 10)    {       for(indeks = 0; indeks < 10; indeks++);      scanf("%d", &a[indeks]);      n++;    }      (n = 0; n < 10; n++) {     printf("%d\n", a[n]);    }  } 

hello , have problem doesn't print array integer number enter in .

it print out -858993460 ten times.

this how looks in cmd. (sorry bad english)

 unesite elemenate niza:   1     /input starts here  3  5  1  0  2  3  5  7  4     /ends here -858993460   -858993460 -858993460 -858993460 -858993460 -858993460  -858993460 -858993460 -858993460 -858993460      /output result press key continue . . . 

the for loop nothing, since ends ; , while loop iterates, indeks 10. suggest following

#include <stdio.h> int main()                                  // correct function type     {     int indeks, a[11], j, rezultat[50];     int n = 0;      printf("unesite elemenate niza\n");      //while (n < 10)                        // delete while loop     //{      for(indeks = 0; indeks < 10; indeks++)  // remove trailing ;         scanf("%d", &a[indeks]);      //n++;                                  // delete unnecessary line     //}       (n = 0; n < 10; n++) {         printf("%d\n", a[n]);     }    return 0;                                // add return value } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -