1173 Array fill I

SemiColon
By -
0
URI Online Judge | 1173

Array fill I

Read a number and make a program which puts this number in the first position of an array N[10]. In each subsequent position, put the double of the previous position. For example, if the input number is 1, the array numbers ​​must be 1,2,4,8, and so on.

Input

The input contains an integer number (V < 50).

Output

Print the stored number of each array position, in the form "N[i] = X", where i is the position of the array and x is the stored number at the position i. The first number for X is V.
Input SampleOutput Sample
1N[0] = 1
N[1] = 2
N[2] = 4
...



Solution:

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

Tags:

Post a Comment

0Comments

Post a Comment (0)