Program to find GCD(greatest common divisor or HCF) and LCM(least common multiple) of two numbers.

Problem Analysis:

The problem is to input the two integers from the user and display their GCD and LCM.for this,the necessary parameters and header files are given below.

 


Input variables          processing variables          Output variables          Necessary header files


x(int)                          a(int)                                   hcf(int)                           stdio.h

y(int)                          b(int)                                   lcm(int)                           conio.h

c(int)


 

Algorithms:

1.start

2.Define a,b,x,y,t,hcf,lcm.

3.Input x.y from the user.

4.Calculation

a=x,  b=y;

while (b!=0)

{

t=b;

b=a%b;

a=t;    }

hcf=a;

lcm=(x*y)/hcf;

5. print the lcm and hcf.

6.stop

 

Codes:

outputs:

Compiling   , Debugging and Testings

enter any two integers:    10   32

GCD=2   and LCM=160

About Programmingfaster

We the teams of programming faster managed to provide an effective information about the codes of different programming languages.Hope you will learn and understand the codes fast and easy. It's absolutely free, expanding and precise. Our main target is to help those new starters and aid them as far as possible to pave their future in the area of programming. Hoping support and recommendations!
This entry was posted in C, precise examples and tagged , , , , , . Bookmark the permalink.

Leave a Reply

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