GCD of two numbers



/* C program to calculate GCd of two numbers */
#include<stdio.h>
int gcd(int a, int b)
{
               int t;                                         /* t=temporoty */
               while(b!=0)
               {
                            if(a<b)                        /* swap a,b if a<b */
                           {
                                 t=a;
                                 a=b;
                                 b=t;
                            }
              t=a;                                             /* t=temporoty */
              a=b;
              b=t%b;
              gcd(a,b);
              }
              return a;
}
int main()
{
              int a,b;
              printf("a, b: ");
              scanf("%d%d",&a,&b);                /* read a,b */
              int g;
              g=gcd(a,b);                  /* calling 'gcd'function and collect return value in g which is gcd */
              printf("%d",g);                             /* print gcd */
}

Sample input and output:
a, b: 24 6
6