C or C++ or Java code to display the output

Write a C or C++ or JAVA code to display the below output

7
14 15
28 29 30 31
56 57 58 59 60 61 62 63

Sample code:

int j = 1;
int value = 7;
printf("%d\n",value);
for(i=0;i<3;i++)
{
    value = value * 2;
    printf("%d", value);
    for(k=1; k<= j ; k++)
    {
        printf("%d", (value+1));
    }
    printf("\n");
    j = 1 + (2*j);
}

Cheers!!!

No comments:

Post a Comment