title: How do I fix the assigning numbers to the variable and the number of occurrence?
body: <p>I managed to formulate a code but I still cannot figure out where I'm getting it wrong, there are two problems the numbers and the number of occurrence. If one is working the other is not.</p>
  <p>Task: Using while loop, write a program that asks a user to input for a positive number let’s say N. The program then asks the user for N number of positive integers. The program is to determine the
  largest value among the numbers and the number of times it occurred.</p>
  <p>What I've Worked on So Far:</p>
  <pre><code>    #include &lt;iostream&gt;
  
  using namespace std;
  
  int main()
  {
      int nnum, x = 1, unum, sum, max = 0,  anum, occ = 0, rem, quo;
  
      cout &lt;&lt; &quot;Input number of positive integers: &quot;;
      cin &gt;&gt; nnum;
      cout &lt;&lt; &quot;Input &quot; &lt;&lt; nnum &lt;&lt; &quot; positive numbers: &quot;;
  
      while (x&lt;=nnum) {
              cin &gt;&gt; unum;
              anum = unum;
              quo = anum;
              sum += unum;
              if (max &lt; unum) {
                  max = unum;
              }
              x++;
  
              while (quo != 0) {
                      rem = quo%10;
                      quo = quo/10;
  
                      if (anum == rem) {
                              occ += 1;
                      }
              }
      }
  
  
  
      cout &lt;&lt; &quot;Highest: &quot; &lt;&lt; max &lt;&lt; endl;
      cout &lt;&lt; &quot;Occurrence: &quot; &lt;&lt; occ;
  
  
      return 0;
  }
  </code></pre>