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
(RationalNumber Class) A rational number is a number that can be represented as the quotient of two integers. For example, 1/3, 5/7, 7/2, and so forth are rational numbers (By 2/1

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

how can i easily make a program?

Project Description: Currently seeking someone who can create me a software application (google chrome crx file_ that will auto add all shoe sizes to cart directly and if not av

Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat

Ask question #write statement that assign random integer to the varaible n in the (100

Introduction:  This assignment requires a knowledge of variables (integers, char types), loops, conditionals, switch, functions, char arrays, string arrays, number arrays, struc

Write a program that reads data into an array of type int. You must use an array. The numbers input are attendance numbers at a conference. Keep a running average, number of events

Here is a program that uses an inline function to compute and return the absolute value of its input argument. # include inline int abs(int x) {                  ret

can you tell me what is c#