Please assist with double parsing / double arithmetic

I'm making this scientific calculator for my project at uni [ which calculates values of various physical quantities ] and I am stuck with a problem in this part of the code :
1
2
3
4
5
6
7
8
9
 
int soln[81];
long double ctr=(1.0*pow(10,80));
long double j;
for(j=80;j>=0;j--)
{
	soln[j]=(ctr)%10;
	ctr=10;
}

What I actually need to do is store the long double number 1 * 10^80 into an array of 81 elements, soln.
Please dont show me how to do that, but show me how to do that using the same kind of looping structure using which I have tried , because I will have to use similar loops to convert numbers into array again and again in the program.

I need to know how to resolve the two errors :
1> subscript is not of integral type
2> '%' : illegal, left operand has type 'long double'

Thank you for taking your time out,
G'day
Last edited on
You cannot use modulus operator on a double, so you can't do that. You will have to divide by powers of 10 and then truncate the decimal to get the current number.
Also your for loop index can't be a double because you are using it to index the array. j needs to be of an integral type.
I'm wanted to use ctr as the counter in the next loop
So what must I do if i want to use numbers as big as ctr=(1.0*pow(10,80)) in the loop as counters ??
Topic archived. No new replies allowed.