I write the code using do while loop that takes a positive integer n, and then displays the polynomial for the octal representation of that integer. Using successive division, as demonstrated in the binary conversion example from the lesson to do this. For example, for n = 157, the program should output the following:
157 = + (5 * 8^0) + (3 * 8^1) + (2 * 8^2)
When this part is working properly, “surround” this code with a loop that gets the value of n from the user, and exits the loop when the value is negative. I used " a" variable for remainder, "i" for power of 8, but when doing the nested loop, i am not getting the n to repeatedly inputed. Please HELP My code is
#include <stdio.h>
#include <math.h>
int main()
{
setvbuf(stdout, NULL,_IONBF,0 );
int n, i = 0, a;
do
{
printf("enter the value of n");
scanf("%i \n", &n);
do
{
a = n % 8;
n /= 8;
printf("+(%i *8^ %i)", a, i);
i++;
} while (n >= 1);
}while(n>0);
return 0;
}