C++ Program to print given series:1 2 4 8 16 32 64 128

#include<iostream.h>
#include<conio.h>

void main()
{
clrscr();
int i;

for(i=1;i<=128;i*=2)
cout<<i<<” “;
getch();
}

35 thoughts on “C++ Program to print given series:1 2 4 8 16 32 64 128”

  1. @pankaj you can print this series by multiplying i by -1 each time like this…….

    for(i=i;i<=128;++i)
    i*=(-1);

    just try it you will definitely get your result……..

  2. mohammad zarrar

    Write a program that takes an integer as an input from user and prints if it is a prime or composite number.Also ask to run again program or not (Do-While) plz solve this programmm

  3. how can i make a program like 2 4 6 8 10 ………N using if statements.Pls solve my code.I think my code is ok.but when i run this program .the console just show me 2.pls solve it.

    #include
    int main()
    {
    int j,product;
    j=2;
    product=1;

    if(j<=10)
    {
    product=product*j;
    printf("%d\n",product);
    j+=2;
    }

    }

  4. 1 2
    1 2 4
    1 2 4 8
    1 2 4 8 16
    1 2 4 8 16 32
    1 2 4 8 16 32 64
    1 2 4 8 16 32 64 128
    1 2 4 8 16 32 64 128 256
    1 2 4 8 16 32 64 128 256 512
    1 2 4 8 16 32 64 128 256 512 1024

Leave a Comment

Your email address will not be published. Required fields are marked *