Friday, 29 April 2016

Solution of URI 1178 :: Array Fill III


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()
{
   int a;
    double N[100],b,c,d;
    scanf("%lf", &b);
    N[a]=b;
    for(a=0; a<100;a++)
    {
        printf("N[%d] = %.4lf\n", a, N[a]);
        b/=2;
        N[a+1]=b;
    }
    return 0;
}

1 comment:

  1. Is not correct:
    You need to do "a = 0", print the first position, then "for(a = 1; ..."
    Why did you declare "c, d" if you didn't use it?

    ReplyDelete

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