programming9
  • Flowcharts
  • Programs
      • Back
      • C Programs
      • C++ Programs
      • Java Programs
      • Python Codes
      • HTML Codes
      • Java Script Codes
      • SQL Codes
  • Tutorials
      • Back
      • Java Tutorials
      • Competitive Programming
      • Python Tutorials
      • C Programming
  • Blog
  • Login

Finding GCD and LCM of Given Numbers using C

Details
Written by: RajaSekhar
Category: C Programs
  • Basic C Programs-4,

 Finding GCD and LCM

/* www.programming9.com */
#include<stdio.h>
int main()
{
    int no1, no2, rem=0, n1,n2;
    printf("Enter Two Non-Zero Integer Mumbers:");
    scanf("%d%d",&no1,&no2);
    n1=no1;
    n2=no2;
    rem=no1%no2;
    while(rem != 0)
    {
        no1=no2;
        no2=rem;
        rem=no1%no2;
    }
    printf("\n GCD of %d and %d is %d", n1,n2,no2);
    printf("\n LCM of %d and %d is %d",n1,n2,(n1*n2)/no2);
return 0; }

 OUTPUT:

Enter Two Non-Zero Integer Mumbers:15 25
 GCD of 15 and 25 is 5
 LCM of 15 and 25 is 75
Previous article: C Program to Check Whether a Number is PALINDROME or Not Prev Next article: C Program for Sum of Squares of Numbers from 1 to n Next
  • C Program to Sort List of Strings
  • C Program for Floyd Triangle
  • C Program to Convert Infix to Postfix Expression using Stack
  • Page Replacement Programs in C
  • Swapping of Two Numbers Using Call By Reference in C
  • C Program to Find Area and Circumference of a circle.
  • C Program to Find Address Locations of Variables
  • C Program to Find Prime Factors of a Given Positive Number
  • C Program to find an Element using Binary Search
  • C Program to Implement STACK Operations Using Pointers
  • C program for Fibonacci Series using do-while Loop
  • C Program to Implement RADIX SORT
  • C Program to Print ASCII values of Characters
  • C Program to Find Area of a Square
  • Binary Search Program in C using Recursive and Non-Recursive Methods
  • Privacy Policy
  • Cookie Policy
© programming9.com 2025
Back to top