Sunday, 16 September 2012

c program gcd(greatest common divisor) of two no using function

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}  


#include <stdio.h>
#include<conio.h>
void gcd (int u, int v)
{
int temp;
printf("enter two numbers\n");
scanf("%d%d",&u,&v);
printf ("The gcd of %i and %i is ", u, v);
while ( v != 0 ) {
temp = u % v;
u = v;
v = temp;
}
printf ("%i\n", u);
}
int main (void)
{
    int u,v;
gcd ( u, v);
gcd ( u, v);
gcd ( u, v);
getch();
return 0;
}

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

No comments:

Post a Comment