Friday, January 21, 2011

Operators and Expressions

This program shows using a cast to evaluate the equation.
#include<stdio.h>
void main()
{
float sum;
int n;
sum = 0;
for( n = 1; n <= 10; ++n)
{
sum = sum + 1/(float)n ;
printf("%2d %6.4f\n", n, sum) ;
}
getch();
}

No comments:

Post a Comment