C Program to Find GCD and LCM of Number using Function

C Program to Find GCD and LCM of Number using Function:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

    int a,b;
    int lcm(int,int);
    int gcd(int,int);
    printf("Enter two numbers to find LCM and GCD\n");

    printf("GCD of %d and %d is %d\n",a,b,gcd(a,b));
    printf("LCM of %d and %d is %d\n",a,b,lcm(a,b));

int gcd(int a,int b)
    int temp=0,gcd;
int lcm(int a,int b)
    int temp=0;


Enter two numbers to find LCM and GCD
10 45
GCD of 10 and 45 is 5
LCM of 10 and 45 is 90

You may also like...

2 Responses

  1. Vinayak says:

    Not understood

    • admin says:

      You must focus on the GCD process. For GCD we have check that MOD of 2nd and 1st number is not equal to zero. If it is zero then the loop will not work and will get answer as it is.
      We have use the logic of swapping. You must try it at least one you will surely get your answer after implementing it properly.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.