- #1

- 208

- 1

## Homework Statement

Write an iterative function

*char* conversion(unsigned int num, int base)*,that converts an integer

*into any*

**num****(**

*base***).**

*base <=10*## Homework Equations

## The Attempt at a Solution

How to transform the following recursive function

**into iterative:**

*conversion()*
Code:

```
#include <stdio.h>
void conversion(unsigned num, unsigned base)
{
if (num / base)
conversion(num / base, base);
printf("%u", num % base);
}
int main()
{
unsigned num, base;
printf("num=");
scanf("%u", &num);
do{
printf("base=");
scanf("%u", &base);
}
while (base < 2 || base > 10);
conversion(num, base);
return 0;
}
```