# C Programming – HackerRank Solution | IT quiz |

### Write a Modular C Programming code to solve an IT quiz, What is the biggest possible team size with the exactly the same number of students

Class A and Class B have 18 and 27 students. Choose teams from each class to play the IT quiz, winning team in both the classes will play in the final match. What is the biggest possible team size with exactly the same number of students?

Input Format

two integer numbers separated by space.

Output Format

Biggest possible team size with exactly the same number of students.

Sample Input 0

```18 27
```

Sample Output 0

```Biggest possible team = 9
```

Sample Input 1

```204 255
```

Sample Output 1

```Biggest possible team = 51
```

Sample Input 2

```148 355
```

Sample Output 2

```Biggest possible team = 1
```

Sample Input 3

```0 1
```

Sample Output 3

```Invalid value
```

Sample Input 4

```1 0
```

Sample Output 4

```Invalid value
```

Sample Input 5

```0 0
```

Sample Output 5

`Invalid value`

Refer to Notes: Notes on Data Structures And Algorithms – Linked List

CODE:

```#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int gcd(int a, int b);
int main() {

int a,b,p;
scanf("%d%d",&a,&b);
if(a<=0 || b<=0)
{
printf("Invalid value");
}
else
{
p=gcd(a,b);
printf("Biggest possible team = %d",p);
}
}
int gcd(int a, int b)
{
int r;
while(a)
{
r=b%a;
b=a;
a=r;
}
return b;
}
```

OUTPUT

```Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

18 27

Biggest possible team = 9
Expected Output

Biggest possible team = 9```

Please find some more codes of 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, and MISC on the below page:

Top 100+ C Programming codes – KLE Technological University 