Friday, 29 April 2016

Solution of URI 1173 :: Array fill I


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 N[10], a, V;
    scanf("%d", &V);
    for(a=0; a<=9; a++)
    {
        N[a]=V;
        printf("N[%d] = %d\n",a,V);
        V*=2;
    }
    return 0;
}

2 comments:

  1. #include
    int main()
    {
    int V,i,N[10],X;
    scanf("%d",&V);
    X=V;
    for(i=0;i<10;i++)
    {
    N[i]=X;
    printf("N[%d] = %d\n",i,N[i]);
    X=X*2;
    }
    return 0;
    }

    reply

    ReplyDelete
  2. #include
    int main()
    {
    int n,i,a,x;
    scanf("%d",&n);

    for(i=0;i<10;i++)
    {
    x=n;
    printf("N[%d] = %d\n",i,x);
    x=x*2;
    n=x;
    }
    return 0;
    }
    reply...

    ReplyDelete

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