Thanks.. I understand bout the char and string.
Here is my new coding.. i try to combine it from wmheric example and mine.
// lab 2, exercise 4, num 1
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void printTriangle (int , char );
int main()
{
int size;
cout << "Enter the input : ";
cin >> size;
printTriangle(size,'#');
for (int i = 1; i < 7; i++)
{
for (int j = 0; j < i; j++)
{
cout << '#';
}
cout << '\n';
}
getch();
return 0;
}
void printTriangle (int size, char ch)
{
for(int row = size; row > 0; row--)
{
for(int column = 0; column < row; column++)
cout<<ch;
cout<<endl;
}
}
Output =
Enter the input : 6
# # # # # #
# # # # #
# # # #
# # #
# #
#
# #
# # #
# # # #
# # # # #
# # # # # #
I already get it but if i want to make it
center,what should i do? I already tried using setw() but what i got was something else. Not like what I want.
Enter the input : 6
# # # # # #
# # # # #
# # # #
# # #
# #
#
# #
# # #
# # # #
# # # # #
# # # # # #