Not Yet Answered # how to use itoa() function to divide a number by 3 ?

sfuo 111 Discussion Starter mayank.dyl Discussion Starter mayank.dyl

0

If you think about it you can divide by just using subtraction and a for() loop. Since you have this function itoa() available I'm assuming you are only using integers, which means you do not have to worry about remainders/decimals.

Not gonna give you any code because you clearly just rewrote the assignment requirements, so give it a shot and if you have any questions post code and outline where you are having issues.

0

Actually this is not my assignment problem. This problem was a part of a written exam.

Since i have never used itoa() function so i am little confused about its usage in dividing a number.

What i have come to know so far is this that itoa() function is used to convert integer to string and it also takes base value which is used to convert the input integer into a desired base for example base 10 to 8, 16 etc.

But the real problem is this that how it relates to dividing a number by 3.

please suggest !

0

okay, after considering your idea of just using subtraction and for loop, i have written following function but it no where makes use of itoa() function and further it assumes that we are not interested in remainder/decimals.

```
int divide(int a, int b) // dividing a by b and returing quotient
{
int A=a;
int B=b;
int n=0, i=0, j;
for (j=0; j<100; j++)
{
i=A-B;
A=i;
if(i<B)
{
n=n+1;
return n;
break;
}
else
n=n+1;
}
}
```

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

I don’t want at this stage work on a big separate project as I've already got plenty ...

I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:

```
try
{
Runtime run = Runtime.getRuntime();
Process pr = ...
```

Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.

btn_addline :

`Private Sub btn_addline_Click(ByVal ...`