write a programm which out put is a triangle
example
5
4 4
3 3 3
2 2 2 2
1 1 1 1 1

Give it a shot and see how it goes.

Actually, here is the code. Your teacher will be impressed! =)

#include<iostream>
#include<windows.h>
#include<iomanip>
#include<math.h>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<string>
using namespace std;
int p[3]={0,0,2};
string doit[8] = {"Plea","se ente","r th", "e siz", "e o", "f yo", "ur tria","ngle: "};
void endit()
{
	cout << endl;
}
void top()
{
	for(p[0];p[0]<p[1]/p[3];p[0]++)
	{
		for(int r=0;r<=p[0];r++)
		cout << p[1]-p[0];
		endit();
	}
}
void questionthoseguys()
{
	cout << doit[0] << doit[1] << doit[2] << doit[3] << doit[4] << doit[5] << doit[6] << doit[7] << doit[8];
	cin >> p[1];
}
void bottom()
{
	for(p[0]=p[1]/p[3];p[0]<p[1];p[0]++)
	{
		for(int r=0;r<=p[0];r++)
		cout << p[1]-p[0];
		endit();
	}
}
void main()
{
	questionthoseguys();
	system("cls");
	endit();
	top();
	bottom();
	endit();
}

....

Actually, here is the code. Your teacher will be impressed! =)
<snipped>

I beg to differ. Please, if you are going to blatantly give the answer
out, at least give a good answer. Not trying to be rude, just telling
the truth.

I beg to differ. Please, if you are going to blatantly give the answer
out, at least give a good answer. Not trying to be rude, just telling
the truth.

You quite obviously didn't get the point of the post. If you looked at the thread description, and what was required you would most likely realize that this is indeed a beginner's assignment, so the OP would have no clue what an array/function/string is, and this is why I gave him that answer.

So quite obviously, since the answer I gave was more advanced
(and more necessary) then what he was looking for, the professor would look over it, and either question the student, or look it up online. Either this, or the OP would look into the examples I had in the project, and learn more C++. So either way it is a win-win for DaniWebs, as he wouldn't get 'free' credit for something he didn't do or understand.

If you read my first post, or any of my posts that regard to these types of threads you would realize that I do not give away solutions for nothing, unless the person has tried their best to accomplish their goal.

Not trying to be rude here, but did you honestly think I would separate the function that drew the triangle into two different functions (requiring me to half each function, and continue the last function where the first left off), and then make a string-array to list the question of, "Please Enter The Size of your Triangle:"(not to mention that the strings within the arrays are fragments of a word.).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.