[求助] 用数组存储商,结果更精确,可是哪儿错了?
我想用数组存储除法运算的商,让结果更精确, 可是结果有错? 程序哪儿错了???
#include "stdio.h"
void main()
{
float a,b;
char c[100];int i;
printf("enter the numbers(a/b):\n");
scanf("%f/%f",&a,&b);
getchar();
if(a>=b)
{
c[0] = (int)(a/b);
c[1] = '.';
}
else
{
c[0] = 0;
c[1] = '.';
}
for(i=2;i<=100;i++)
{
a = (a/b - (int)(a/b)) * b;
c[i] = (int)(a/b);
}
printf("the result is: ");
for(i = 0; i <= 100; i ++)
printf("%d",c[i]);
printf("\n");
}