Decrease & Increase

VertikaL

#include<iostream.h>
#include<conio.h>
int main()
{
int n=1;
int j;
for(j=5;j>=n; j–)
{cout<<j;}
getch();
return 0;
}

horizontal

#include<iostream.h>
#include<conio.h>
int main()
{
int n=10;
int j;
for(j=1;j<=n; j++)
{cout<<j<<endl;}
getch();
return 0;
}

#include <iostream.h>
#include <conio.h>
int main ()
{
int hasil;
int n=5;
for(int i=1;i<=n;i++)
{
hasil=i; //1
for(int j=1;j<=i;j++)
{
cout << ” ” << hasil;
hasil=hasil+i;
}
cout << “\n”;
}
getch();
return 0;
}

kalau dibalik

#include <iostream.h>
#include <conio.h>
int main ()
{
int hasil;
int n=1;
for(int i=5;i>=n;i–)
{
hasil=i; //1
for(int j=5;j>=i;j–)
{
cout << ” ” << hasil;
hasil=hasil+i;
}
cout << “\n”;
}
getch();
return 0;
}

#include <iostream.h>
#include <conio.h>
int main ()
{
int hasil;
int n=5;
for(int i=1;i<=n;i++)
{
hasil=i; //1
for(int j=1;j<=i;j++)
{
cout << ” ” << hasil;
hasil=hasil*hasil;
}
cout << “\n”;
}
getch();
return 0;
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: