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