title: Finding the second highest number
body: <p>I want to find the second highest number from a sequence <em>without using an array</em>.</p>
  
  <p>The instructions are the following.</p>
  
  <blockquote>
    <p>You are given a sequence of integers as input, terminated by a
    -1. (That is, the input integers may be positive, negative or 0. A -1
    in the input signals the end of the input.) </p>
    
    <p>-1 is not considered as part of the input.  </p>
    
    <p>Find the second largest number in the input. You may not use arrays.</p>
  </blockquote>
  
  <p>What I did is this.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int i, a, temp, sec;
      while (1) {
          scanf("%d", &amp;a);
          if (a == -1) ;
              break;
  
          temp = a;
          while (1) {
              scanf("%d", &amp;a);
              if (a == -1) {
                  break;
              }
              if (a &gt; temp) 
                  sec = temp;
              else 
                  sec = a;
          }
      }
  
      printf("%d", sec);
      return 0;
  }
  </code></pre>
  
  <p>Sample test cases will be like the following ones.</p>
  
  <pre><code>Sample Test Cases
  Input   
  Test Case 1 
  -840 -288 -261 -337 -335 488 -1
  Output
  -261
  Test Case 2 
  -840 -335 -1
  Output
  -840
  </code></pre>
  
  <p>I don't know where to get started and where I am getting wrong.</p>