C program for function of divider , C/C++ Programming

C Program for FUNCTION OF DIVIDER

int gcd(int , int);

void main()

{

          int m=0,n=0,k=0;

          clrscr();

          printf("ENTER THE FIRST DIGIT: ");

          scanf("%d",&m);

          printf("ENTER THE SECOND DIGIT: ");

          scanf("%d",&n);

          k=gcd(m,n);

          printf("THE GREATEST COMMON DIVISER %d AND %d IS %d",m,n,k);

 

          getch();

}

int gcd(int m , int n)

{

          int temp=0;

          printf("%d  %d\n",m,n);

while(n!=0)

          {

                   if(n>m)

                   {

                             temp=m;

                             m=n;

                             n=temp;

                             printf("%d  %d\n",m,n);

                   }

                   if(n==0)

                   {

                             return(m);

                   }

                   m=m%n;

                   printf("%d  %d\n",m,n);

          }

}

OUTPUT :

OUTPUT :

     ENTER THE FIRST DIGIT : 20

ENTER THE SECOND DIGIT :   1

20 1

  0 1

  1 0

THE GREATEST COMMON DIVIDER 20 & 1 IS 1

 

Posted Date: 9/10/2012 7:53:16 AM | Location : United States







Related Discussions:- C program for function of divider , Assignment Help, Ask Question on C program for function of divider , Get Answer, Expert's Help, C program for function of divider Discussions

Write discussion on C program for function of divider
Your posts are moderated
Related Questions
write a c++ program to update employee records

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules:

What does throw; (with no exception object after the throw keyword) mean? Where would I employ it? A: You should see code that looks something like this: class MyException

What is the difference among const char *myPointer and char *const myPointer?  A: Const char *myPointer is a non constant pointer to constant data; whereas char *const myPointer

Introduction to Classes Object-oriented programming (OOP) is a conceptual approach to design programs. It can be executed in many languages, whether they directly support OOP c

Luminous Jewels - The Polishing Game Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various lum

Compiler Design - Limit In The Method Instructions

wap to count the numof string present in a word

getting a palindrome using minimum replacement

Employ operator () instead of operator[]. While you have multiple subscripts, the cleanest way to do it is along with operator () instead of with operator[]. The reason is that