Greatest common divisor of two non-negative numbers


#include<stdio.h>
//main function
main ()
{
     int u, v;
     printf("\nEnter the two numbers to find GCD.\n");
     scanf("%d%d",&u,&v);
     gcd(u,v);
     getch();
}
//calling function
gcd(u,v)    //gcd(u,v) being called by main function
{
int temp;
printf("The gcd of %d and %d is ",u,v);
while(v!=0)
    {
    temp=u%v;
    u=v;
    v=temp;
    }
printf("%d\n",u);
}

Comments

Popular posts from this blog

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Customize User's Profile in ASP.NET Identity System