Hello. I am having trouble with one of my labs in my programming class. It seems to be simple and to the point, but I'm not sure if I understand it all. This is the question:
Write a program to compute the partial sum of harmonic series
1 + 1/2 +1/3 + ... + 1/n
and display the intermediate partial sums. Hint: use a for loop.
This is what I came up with. I know it's not 100% correct, but I got myself stated, I just need a push in the right direction.
#include <stdio.h>
int main (void)
{
int n;
printf("Enter a number:");
scanf("%d", &n);
int i, sum = 0;
for (i=1; i<=n; i=i+1)
{
sum = sum + (i * i);
}
printf ("The intermediate partial sums are:\n", sum);
return(0);
}
thank you in advance