Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a few problems with your code:</p> <ul> <li>The duplicate function is inside the main function.</li> <li>i is declared multiple times</li> <li>There should not be a semicolon after your first for loop.</li> <li>The hold variable is not being used for anything. It is only being assigned a value.</li> <li>num[i=1] - not sure what you are trying to do here, but the i=1 is setting i to 1.</li> <li>In your first for loop, your condition is i &lt; SIZE - 1, meaning it will loop 19 times, not 20. It should be i &lt; SIZE or i &lt;= SIZE - 1.</li> <li><p>Your if statements should use braces ({}) for each if/else, or not at all.</p> <pre><code>if (test) { // code } else { // code } </code></pre> <p>or</p> <pre><code>if (test) // code else // code </code></pre></li> </ul> <p>As for the logic:</p> <ul> <li>You are only getting one integer, which you are not putting in the numbers array. You will need to get 20 integers one by one and check the array each time the user enters a number.</li> <li>The duplicate function should probably take a second parameter, the number that you want to check for. The if statement would check if num[i] equals the number you are looking for.</li> <li>Remember to initialize the array values and only check values that you have set. For example, when the user enters the third number, you only want to check the first 2 numbers in the array to see if it already exists.</li> </ul> <p>PS: Please try to indent your code properly. Many people will not even try to help if it is not indented properly.</p>
    singulars
    1. This table or related slice is empty.
    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.
    1. This table or related slice is empty.
    1. VO
      singulars
      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