i want solution of a c prog using functions ie to find lcm and gcd using functions in same program but to find lcm we will be using formula lcm=(a*b)/gcd;
please help me out
this is my code if modifiction are to be done then please send me modified code
gcd(int,int);
lcm(int,int);
void main()
{
int a,b,gcd1,lcm1;
clrscr();
printf("Enter the values for a and b");
scanf("%d %d",&a,&b);
gcd1=gcd(a,b);
lcm1=lcm(a,b);
printf("\n gcd is %d \n lcm is %d",gcd1,lcm1);
}
gcd(int c,int d)
{
int r;
do
{
r=c%d;
c=d;
d=r;
}while(r!=0);
return c;
}
lcm(int a,int b)
{
int lc;
lc=(a*b)/gcd1;
return lc;
}
pooja.singh.3950 -3 Newbie Poster
shoroq.salamh.3 commented: Matching Subscripts In Arrays and For Loop Issues +0
maria.clay.397 commented: declearing a function +0
pooja.singh.3950 -3 Newbie Poster
Gonbe 32 Newbie Poster
pooja.singh.3950 -3 Newbie Poster
subhraakasuny -3 Light Poster
Gonbe 32 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.