我正在尝试计算p1=(1/1)*(1/2)*...*(1/n)
,但出了点问题,这printf
给了我0.000...0
#include <stdio.h>
int main(void) {
int i,num;
float p3;
do {
printf ("give number N>3 : \n" );
scanf( "%d", &num );
} while( num <= 3 );
i = 1;
p3 = 1;
do {
p3=p3*(1/i);
printf( "%f\n",p3 );
} while ( i <= num );
printf("\nP3=%f",p3);
return 0;
}