Note that there are some explanatory texts on larger screens.

plurals
  1. POGet the value of array to use in sort?
    primarykey
    data
    text
    <p>I need to get the result from K (number of students) but in case 2 ... program fills up all 30 places in the array with (if K=2) two number and other 28 are some kind of 38392839238 .. .some thing like that, here is my code:</p> <pre><code>int main() { int i,n,k; unsigned int m[30], a[30], b[30]; int ch=0, nech=0; cout&lt;&lt;"Number of students (max30)";cin&gt;&gt;k; for(i=0; i&lt;k; ++i) { cout&lt;&lt;i+1&lt;&lt;". Student number: "; do { cin&gt;&gt;m[i]; } while(!(m[i]&gt;=1e7 &amp;&amp; m[i]&lt;1e8)); if(m[i]%2==0) { a[ch]=m[i]; ch++; } else { b[nech]=m[i]; nech++; } } cout&lt;&lt;endl; cout&lt;&lt;"\nAll numbers: "&lt;&lt;endl; for(i=0; i&lt;k; ++i) cout&lt;&lt;m[i]&lt;&lt;"\t"; loop: cout&lt;&lt;endl; cout&lt;&lt;"\nChoose 1 to see Even and Odd numbers: "; cout&lt;&lt;"\nChoose 2 to see ascending order: "; cout&lt;&lt;"\nChoose 3 to exit: "; cout&lt;&lt;"\nEnter Your choise: "; cin&gt;&gt;n; switch(n) { case 2: { { int e=sizeof(m) / sizeof(m[0]); sort(m,m+e); for(i=0;i&lt;e;++i) cout&lt;&lt;"\n"&lt;&lt;m[i]&lt;&lt;' '; } } goto loop; } } </code></pre> <p>This program wants to enter the number of students in class, after that it wants to enter their number in class and in CASE 2 i it need to make them in ascending order. For example: Number of students in class: 2 1. Student number: 12345678 2. Student number: 55555555</p> <p>and when you hit 2 for case2 it needs to make their ascending order, so result must be: 12345678 55555555 (from min to max). My program makes it but on the other 28 places (my array must be max 30) it puts another number = 3435973836</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload