I had to create a c code that gets a number, returns how many digits it has,the digits sum, the digits product, to check if the digits sum is equal to product if yes return "1" else return 0, and in the end write a program the prints the first 20 numbers that the sum of their digits equals to the product. however in the end my program just prints the numbers 0-19. i know the problem must be in my while loop but i cant spot it can someone help me. my code is below:

#include <stdio.h>
#include <math.h>
#define r 10

int get_nums(int a) //(gets an integer number and returns how many digits it has)

{
int nums,p,q;

p=10;
q=a/p;
nums=1;

while(a/p!=0)
{
p=pow(r,nums);
a=q;
nums++;
}
return nums;
}

int get_sum(int a) // (gets an inter number and returns the sum of its digits)

{
int sum,nums,p,q;

nums=get_nums(a);
sum=0;
for(p=0;p<nums;p++)
{
q=a%r;
a=a/r;
sum+=q;
}
return sum;
}

int get_product(int a) //( get an integer number and returns the product of its digits)

{
int p,sum,nums,q,product;

nums=get_nums(a);

for(p=0;p<nums;p++)
{
q=a%r;
a=a/r;
product*=p;

}
return product;
}

int check_num(int a) //(gets a number checks if the product of its digits is equal to the some if its is return 1 otherwise return 0)

{
int p,sum,nums,product;

nums=get_nums(a);
sum=get_sum(a);
product=get_product(a);

if(product==sum)
{
return 1;
}
else
{
return 0;
}
}

main()
{
int a,sum,product,check,nums,i;

a=0;
i=0;
nums=get_nums(a);
sum=get_sum(a);
product=get_product(a);
check=check_num(a);


while(check == 1)
{
printf("%6d",a);
a++;
i++;
if(i==20)
{
break; // (after 20 numbers are printed the loop should be exited)
}
}
while (check!=1)
{
a++;
continue; //( if check !=1 increase a by one and check for the next integer).
}
printf("\n");
}

There are a few issues with your code that are causing it to print only the numbers 0-19. Let's go through the issues step by step:

1. In the `get_product` function, you are not initializing the `product` variable before multiplying it with `p`. This will lead to undefined behavior. You need to initialize `product` to 1 before the loop.

```c
int get_product(int a) {
int p, sum, nums, q, product;

nums = get_nums(a);
product = 1; // Initialize product to 1
for (p = 0; p < nums; p++) {
q = a % r;
a = a / r;
product *= q;
}
return product;
}
```

2. In the `main` function, you are not updating the `check` variable inside the loop to check if the current number satisfies the condition. You need to update `check` inside the loop.

```c
while (check == 1) {
printf("%6d", a);
a++;
i++;
check = check_num(a); // Update check for the next number
if (i == 20) {
break; // Exit the loop after printing 20 numbers
}
}
```

3. The second `while` loop after the first `while` loop is not necessary. You can remove it and the `continue` statement.

4. Finally, you forgot to update the `check` variable before the first `while` loop. You need to update `check` before entering the loop to check if `a` satisfies the condition.

Here's the updated code:

```c
#include <stdio.h>
#include <math.h>
#define r 10

int get_nums(int a) {
int nums, p, q;

p = 10;
q = a / p;
nums = 1;

while (a / p != 0) {
p = pow(r, nums);
a = q;
nums++;
}
return nums;
}

int get_sum(int a) {
int sum, nums, p, q;

nums = get_nums(a);
sum = 0;
for (p = 0; p < nums; p++) {
q = a % r;
a = a / r;
sum += q;
}
return sum;
}

int get_product(int a) {
int p, sum, nums, q, product;

nums = get_nums(a);
product = 1;
for (p = 0; p < nums; p++) {
q = a % r;
a = a / r;
product *= q;
}
return product;
}

int check_num(int a) {
int p, sum, nums, product;

nums = get_nums(a);
sum = get_sum(a);
product = get_product(a);

if (product == sum) {
return 1;
} else {
return 0;
}
}

int main() {
int a, sum, product, check, nums, i;

a = 0;
i = 0;
nums = get_nums(a);
sum = get_sum(a);
product = get_product(a);
check = check_num(a);

check = check_num(a); // Update check for the first number
while (check == 1) {
printf("%6d", a);
a++;
i++;
check = check_num(a); // Update check for the next number
if (i == 20) {
break; // Exit the loop after printing 20 numbers
}
}
printf("\n");

return 0;
}
```

The issue in your code is that you are not updating the value of the "check" variable inside the first while loop. As a result, the loop continues indefinitely because the condition check==1 is always true.

To fix this, you need to update the value of the "check" variable inside the loop. Here's what you need to change:

```
while(check == 1)
{
printf("%6d",a);
a++;
i++;
if(i==20)
{
break; // (after 20 numbers are printed the loop should be exited)
}
check = check_num(a); // Update the value of check
}
```

This change will ensure that the loop stops when the "check" variable is no longer equal to 1.

Apart from this issue, there is also a problem in your get_product function. The variable "product" is not initialized before the loop starts. You should initialize it to 1. Here's the corrected code:

```
int get_product(int a) // get an integer number and returns the product of its digits
{
int p, nums, q, product;

nums = get_nums(a);
product = 1; // initialize product to 1

for (p = 0; p < nums; p++)
{
q = a % r;
a = a / r;
product *= q;
}
return product;
}
```

With these changes, your program should now print the first 20 numbers where the sum of their digits equals the product.