A small program using C, to find the largest of the four numbers using if, else
<p>I am new to C programming and also "programming". Less than one month so far. I made a small program which prints the largest and smallest integers among the four input numbers. Is there any shortest way using the basic c programming methods?</p>

<pre><code>#include &lt;stdio.h&gt;

main()
{   
    int a, b, c, d, y;

    printf("Enter four integers (separate them with spaces): ");
    scanf("%d %d %d %d", &amp;a, &amp;b, &amp;c, &amp;d);

    if (a&gt;b &amp;&amp; a&gt;c &amp;&amp; a&gt;d){
      if (b&lt;c &amp;&amp; b&lt;d){
        y = b;
      }
      else if (c&lt;b &amp;&amp; c&lt;d){
        y = c;
      }
      else if (d&lt;b &amp;&amp; d&lt;c){
        y = d;
      }

      printf("Largest: %d\n", a);
      printf("Smallest: %d", y);
    }
    else if (b&gt;a &amp;&amp; b&gt;c &amp;&amp; b&gt;d) {
      if (a&lt;c &amp;&amp; a&lt;d){
        y = a;
      }
      else if(c&lt;a &amp;&amp; c&lt;d){
        y = c;
      }
      else if(d&lt;a &amp;&amp; d&lt;c){
        y = d;
      }

      printf("Largest: %d\n", b);
      printf("Smallest: %d", y);
    }
    else if (c&gt;a &amp;&amp; c&gt;b &amp;&amp; c&gt;d)
    {
      if (a&lt;b &amp;&amp; a&lt;d){
        y = a;
      }
      else if(b&lt;a &amp;&amp; b&lt;d){
        y = b;
      }
      else if(d&lt;a &amp;&amp; d&lt;b){
        y = d;
      }

      printf("Largest: %d\n", c);
      printf("Smallest: %d", y);
    }
    else if (d&gt;a &amp;&amp; d&gt;b &amp;&amp; d&gt;c) {
      if (a&lt;b &amp;&amp; a&lt;c){
        y = a;
      }
    else if(b&lt;a &amp;&amp; b&lt;c){
      y = b;
    }
    else if(c&lt;a &amp;&amp; c&lt;b){
      y = c;
    }

    printf("Largest: %d\n", d);
    printf("Smallest: %d", y);
  }

  return 0; 
}
</code></pre>