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

Program to calculation of mortgage interest rates, This assignment builds o...

This assignment builds on Homework 3. The two major modifications are the instruction of pointers and the calculation of mortgage interest rates. Requirements for Project 2:

Friends of classes, Define the following Window class : - integer  data mem...

Define the following Window class : - integer  data members, width and height - a constructor  that accepts two integer  parameters  (width followed by height) and uses them to ini

Reverse a string - c ++ program, Reverse a string - C ++ program: Writ...

Reverse a string - C ++ program: Write a program in c to reverse a string. int main() {     Stack theStack;     String reverse("reverse");       cout

Write a c program to input a floating point number, Step 1 Define the start...

Step 1 Define the start of the program    It should be noted that within C all commands should end in a semi-colon. For most of your programs the definition of a program header as

What is a recursive function, Question 1 Write a program in ‘C' to check w...

Question 1 Write a program in ‘C' to check whether a given number is even or odd Question 2 Explain while and do... while loop with an example Question 3 Write a program

Write a program to test the class, Problem Implement a class called emp...

Problem Implement a class called employee that contains name, employee number and department code. Include a member function getdata() to get data from user and store it in the

Board Coloring , In this problem you are given a board in which some of the...

In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color. Fill the other elements in the board, suc

How do i develop a subscript operator for a matrix class?, Employ operator ...

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

D, drawbacks in assignments in engeenirng

drawbacks in assignments in engeenirng

Usb photobackup, Project Description: Prepare software that will work with ...

Project Description: Prepare software that will work with our USB hardware that easily lets you backup all the pictures in your computer into the USB stick in one single step. Once

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