• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Sunday, May 27, 2012

C++ - TRIANGEL ROW


Hi.. welcome to my blog… this is blog want giving you many IT knowledge. From dekstop programming until web programming to be found in this blog… so.. let’s do read this article… have fun and enjoy it..

Triangel Row or in Indonesian is "DERET SEGITIGA" with using C++, is element in to learn C++... This programing very needed...

This Triangel Row using "FOR", If you want, can using  "DO - WHILE", but more easy using for, and familiar...

This program is elementer... for more hard, you can try make "FIBONANCI ROW" or "TRIANGEL PASCAL"...

And... This TRIANGEL ROW with For... you can copy this coding in your aplication.


Example 1

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 3; a >=1; a--)
{
For (b = 1; b <= a; b++)
Cout << a;
Cout << endl;
}
Getch();
}


To result :

333
22
1


Example 2 :

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 3; a >=1; a--)
{
For (b = 3; b >= a; b--)
Cout << a;
Cout << endl;
}
Getch();
}


To result :

3
32
321


Example 3 :

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 3; a >=1; a--)
{
For (b = 3; b >= a; b--)
Cout << b;
Cout << endl;
}
Getch();
}


To result :

3
22
111


Example 4 :

#include <iostream.h>
#include <conio.h>
Main()
{
Inta,b;
For (a = 1; a <= 3; a++)
{
For (b = 1; b <= a; b++)
Cout << b;
Cout << endl;
}
Getch();
}


To result
1
12
123


Example 5 :

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 1; a <= 3; a++)
{
For (b = 1; b <= a; b++)
Cout << a;
Cout << endl;
}
Getch();
}


To result :

1
22
333


Example 6 :

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 3; a >=1; a--)
{
For (b = 1; b <= a; b++)
Cout << b;
Cout << endl;
}
Getch();
}


To result : 123
12
1


Example 7 :

#include <iostream.h>
#include <conio.h>
Main()
{
Int a,b;
For (a = 1; a <=1; a++)
{
For (b = 3; b >= a; b--)
Cout << b;
Cout << endl;
}
Getch();
}


To result :

321
32
3


Example 8 :

#include <iostream.h>
#include <conio.h>
Main()
{
Inta,b;
For (a = 1; a <=1; a++)
{
For (b = 3; b >= a; b--)
Cout << a;
Cout << endl;
}
Getch();
}


To result :

111
22
3

No comments:

Post a Comment