#include <stdio.h>
int main(int argc,int *argv[])
{
float fenzi = 2,fenmu = 1;
int i=0,temp,n = 20;
float result =0.0;
do
{
printf("%.0f/%.0f ",fenzi,fenmu); // print item value.
result += fenzi / fenmu;
temp = fenzi + fenmu;
fenmu = fenzi;
fenzi = temp;
i++;
if ( i % 5 == 0) //if item is 5,begin break line.
{
printf("\n");
}
}while (i < n);
printf("\nresult is %f\n",result);
system("pause");
return 0;
}
|