title: How to get the GCD of command line argument integers entered by the user after './a.out' in any order?
body: <p>This program returns the GCD of the command line
  args inputed by the user ONLY from least to greastest.
  For example:</p>
  
  <p>User input:  './a.out 5 10 15 20 25 '</p>
  
  <p>This program returns: "The GCD of the command line args is 5"</p>
  
  <p>However, the problem I am running into is if the user types for example:</p>
  
  <p>User input: './a.out 15 10 5 25 20'</p>
  
  <p>This program returns: 15</p>
  
  <p>Can someone tell me how to fix this issue?</p>
  
  <p>This is what I am aiming for:</p>
  
  <p>If user input: './a.out 15 10 5 25 20'</p>
  
  <p>This program should return: 5</p>
  
  <pre><code>//Header Files
  #include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  
  //Main Method
  int main(int argc, char *argv[]){
  
  //Declared variables here and print statements
   int i,x,y,min;
   printf("Number of command line args is %d\n", argc);
   printf("The GCD is:\t");
  
   //This is the main while loop
   while( x !=0 &amp;&amp; y !=0 &amp;&amp; y != x){
  
   if(x&lt;y){
    y=y-x;
   }//End first IF statement
   if(y&lt;x){
    x-x-y;
   }//End second IF statement
   }//End while loop
  
   //This function returns the converted integral number as an int value
    x=atoi(argv[i]);
    for(i=2;i&lt;argc;i++){
    y=atoi(argv[i]);
     }
  
     //The following code gets the GCD and prints from the command line
     min = (x&gt;y)?x:y;
    for(i=min;i&gt;=1;--i){
    if(x%i==0 &amp;&amp; y%i==0){
    for(i=1;i&lt;argc;i++){
     printf("%s\n", argv[i]);
      break;}//End for loop
      }//End IF statement
     }//End For loop
    }//End of MAIN
  </code></pre>