Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
double a,b=1,c, S=0;
for(a=1; a<=100; a++)
{
c=1/a;
S+=c;
}
printf("%.2lf\n",S);
return 0;
}
#include
ReplyDeleteint main()
{
int i;
float sum=0;
for(i=1;i<=100;i++)
{
sum+=(float)1/i;
}
printf("%.2f\n",sum);
return 0;
}
reply...
#include
ReplyDeleteint main()
{
int i;
float sum=0;
for(i=1;i<=100;i++)
{
sum+=(float)1/i;
}
printf("%.2f\n",sum);
return 0;
}