```
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

## Recommended Answers

Jump to PostYour GCD function will divide by zero when you enter 0 as its second argument. You can also supply negative numbers. You're lacking return types as well.. I assume that you don't feel the need to check your arguments as you have full control over them. You should still assert …

Jump to Posti want a simple code using simple c functions i'm just learning c so in simple code is it possible

The code I posted is almost identical to the one you posted yourself. That should be simple for you, unless you copy pasted the code in your starting …

## All 5 Replies

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 learning and sharing knowledge.