blob: 93136c7b1ea8245da5eba1381b87d6e549f725e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
// Example 3.5
//Output of program shows round-off errors that can occur in computation of floating point numbers
//Sum of n terms of 1/n
count=1;
sum1=0;
n=input("Enter value of n:");
term=1.0/n;
while(count<=n)
sum1=sum1+term;
count=count+1;
end
printf("Sum= %f",sum1);
|