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
Mixed Mode Expressions and Implicit type Conversions A mixed mode expression is one in which the operands are not of the similar type. In this case, the operands are converted


(a) Define a procedure (deep-member x e) that takes a list x and an element e and returns #t if the element e is in the list or in any lists that the list x contains. e.g., (dee

Problem: (a) Using a class hierarchy of your own choosing, with at least TWO subclass levels, show (i) the use of abstract and concrete forms of Java class and method in you


Aim: To implement a program for dynamic data structure(linked list). Code:                       class node {             int data;             node *next;

Abstraction is of the process of hiding unwanted details from the user

Polymorphism C++ supports this idea - that different objects do "the right thing "- by function polymorphism and class polymorphism. Poly means many, while morph means form.

smugglers transfer the messages from one to another by using the mobile

write aprogram for random -search to implement if a[i]=x;then terminate other wise continue the search by picking new randon inex into a