Sunday, 27 March 2016

Solution of URI 1155 :: S Sequence


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;
}

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include
    int main()
    {
    int i;
    float sum=0;
    for(i=1;i<=100;i++)
    {
    sum+=(float)1/i;
    }
    printf("%.2f\n",sum);
    return 0;
    }
    reply...

    ReplyDelete
  3. #include
    int main()
    {
    int i;
    float sum=0;
    for(i=1;i<=100;i++)
    {
    sum+=(float)1/i;
    }
    printf("%.2f\n",sum);
    return 0;
    }

    ReplyDelete

Note: only a member of this blog may post a comment.