LCM and GCD of Two Numbers in C. It is the basic program mathematical programming for new beginners to understand the c program. LCM is an abbreviation for Least Common Multiple. A multiple is the result of multiplying a number by a whole number (greater than 0). A factor is a number that when multiplied by a whole number yields that number.

#include<stdio.h> int main() { int number1, number2, mp; printf("Enter the numbers"); scanf("%d %d", &number1, &number2); if(number1>number2) mp=number1; else mp=number2; while(1) { if((mp%number1==0) && (mp%number2==0)) break; else mp++; } printf("\nLCM(%d,%d) = %d", number1, number2, mp); return 0; }

Output:

Enter the numbers

45

67

LCM(45,67) = 3015

## Uses of LCM in C Program

The lcm is the “lowest common denominator” (lcd) that can be used before adding, subtracting, or comparing fractions. The lcm of more than two integers is well defined as well: it is the smallest positive integer that is divisible by each of them.

To break things down into smaller sections. To distribute any number of sets of items equally into their largest grouping. To determine how many people we can invite. To group or arrange something into rows or groups.

## Post Increment in C

A post-increment operator is used to increase the value of a variable after the expression has been completely executed. The value is first used in an expression and then incremented in the Post-Increment.

## While Loop in C

A while loop is a control flow statement in most computer programming languages that allows code to be executed repeatedly based on a given Boolean condition. The while loop can be viewed as a looping if statement.

## Return Statement in C

A return statement in computer programming causes execution to exit the current subroutine and resume at the point in the code immediately after the instruction that called the subroutine, known as its return address. The return statement returns the execution flow to the function from which it was called. This statement does not require any conditional statements. Using this program we can execute the LCM and GCD of Two Numbers in C.

Python Program to Print Array Elements

Smallest Element in Array Python

Ascending Order Program in Python Using For Loop

Student Mark List Program in Python

Area of Triangle in Python Program

Program to Calculate Area of Square in Python

Python Program to Calculate Area of Triangle