print following series pattern

series program in c
print following series 1 2 3 6 9 18 27 54.....

#include<stdio.h>
int main()
{
    int x=1,y=2,j,n=10;
    prjntf("%d %d ",x, y);
    for(j=3;j<=n;j++)
    {
        if(j%2==1)
        {
            x=x*3;
            printf("%d ",x);
        }
        else
        {
            y=y*3;
            printf("%d ",y);
        }
    }
}

Related Posts