forked from ACMAJCE/hack-fest-21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlcd.c
More file actions
34 lines (31 loc) · 753 Bytes
/
lcd.c
File metadata and controls
34 lines (31 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<stdio.h>
int find_lcm(int, int); // function prototype declaration
int main()
{
printf("\n\n\t\tStudytonight - Best place to learn\n\n\n");
int a, b, lcm;
printf("\n\nEnter 2 integers to find LCM of:\n");
scanf("%d%d", &a, &b);
lcm = find_lcm(a,b); // function call
printf("\n\n LCM of %d and %d is: %d\n\n", a, b, lcm);
printf("\n\n\t\t\tCoding is Fun !\n\n\n");
return 0;
}
int find_lcm(int a, int b) // function definition
{
/*
static variable is initialized only once
for each function call
*/
static int temp = 1;
if(temp%a == 0 && temp%b == 0)
{
return temp;
}
else
{
temp++;
find_lcm(a,b);
return temp;
}
}