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

Assignment Help:

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

 


Related Discussions:- C program for function of divider

Padovan.., count the number of string in n-th padovan string

count the number of string in n-th padovan string

I need website product section search box coding section fix, I need websit...

I need website Product section search box coding section fix Project Description: On our products section in the search box it only searches the name and title of our product

C++ Program Please see where i do mistake, #include #include #include ...

#include #include #include #include #include class Employee { private: char *Name; //Set them as pointers... int IdNumber; char *Department; char *Position; public: voi

Optimized nic driver for windows compact 7, Optimized NIC Driver for Window...

Optimized NIC Driver for Windows Compact 7 for Hard Real Time Communication Project Description: I am seeking an optimized driver (miniport driver) that will be used for sele

Board coloring, n this problem u given a board in which some of the element...

n this problem u given a board in which some of the elements are placed as shown in diagram below .each element represent a color .fill the other elements in the board such that no

Define a complex number in c program, Define a complex number in c program:...

Define a complex number in c program: class complex                                 {                                   private:                                 in

C program coding, write a c program to compute a padovan string

write a c program to compute a padovan string

Is probable to encompass virtual constructor? if yes, Is it probable to enc...

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?

Create a programming system, Your task is to create a programming system fo...

Your task is to create a programming system for a ferry. The ferry transports passengers and vehicles (cars, busses, lorries and bicycles). The ferry has space for 200 passengers a

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd