#include
#include
int hcf(int a,int b);
int lcm(int x,int y);
void main()
{
int n,ch,num[10],hc,lc,i;
clrscr();
printf("\nEnter the value of n:"); //reading numbers
scanf("%d",&n);
printf("Enter the %d numbers:",n);
for(i=0;i
hc=num[0]; //calculating hcf
for(i=1;i
printf("\nThe HCF is %d",hc);
lc=num[0]; //calculating lcm
for(i=1;i
printf("\nThe LCM is %d",lc);
getch();
}
int hcf(int a,int b) //hcf function
{
if(b==0)
return a;
else
return hcf(b,a%b);
}
int lcm(int x,int y) //lcm function
{
int l;
l=x*y/hcf(x,y);
return l;
}
No comments:
Post a Comment