C++ Syntax Program Help

C++ Syntax Program Help

Page 1 of 1

4 Replies - 12505 Views - Last Post: 06 December 2006 - 01:41 AM Rate Topic: -----

#1 action   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-December 06

C++ Syntax Program Help

Posted 05 December 2006 - 08:54 PM

I have to write a tree program for my computer science 1st year class. My grade depends on it and this is as far as I can get. Any help would greatly be appreciated. The attached image is what the final product should look like.


#include <iostream.h>
#include <math.h>


void main()
{

int i,j;
cout << endl << "******** FOURTY BONUS POINTS FOR A HAPPY CHRISTMAS !! *********" << endl << endl;
for(i = 1; i <= 20; i++)
{

for(j=1; j<=i; j++)
{
cout << "* " ;
}
cout << endl;


}

cout << endl << endl << "(:-) your program must be less than 15 lines long to be cool :-) ) " << endl;
}

Sorry I realized I didn't attach an image. Here it is.

Attached image(s)

  • Attached Image

This post has been edited by action: 05 December 2006 - 08:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: C++ Syntax Program Help

#2 eXceed69   User is offline

  • "Super Sentai Knight Of DawN"
  • member icon

Reputation: 8
  • View blog
  • Posts: 688
  • Joined: 12-November 06

Re: C++ Syntax Program Help

Posted 05 December 2006 - 09:29 PM

you already done it..any else,sir??
Was This Post Helpful? 0
  • +
  • -

#3 Xing   User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: C++ Syntax Program Help

Posted 05 December 2006 - 09:34 PM

See this
#include <iostream>

using namespace std;
int main()
{

int i,j;
cout << endl << "******** FOURTY BONUS POINTS FOR A HAPPY CHRISTMAS !! *********" << endl << endl;
int k=2;
int col=20;
for(i = 0; i < 10; i++)
{

	for(int x=0;x<(col-k)/2;++x)
		cout<<" ";

	for ( j=0; j < k; ++j)
		cout << "*";
	k += 2;
	for(int x=0;x<(col-k)/2;++x)
		cout<<" ";

cout << endl;
}

cout << endl << endl << "(:-) your program must be less than 15 lines long to be cool :-) ) " << endl;
}

This post has been edited by Xing: 05 December 2006 - 09:34 PM

Was This Post Helpful? 0
  • +
  • -

#4 action   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-December 06

Re: C++ Syntax Program Help

Posted 05 December 2006 - 10:51 PM

when i go to compile that it gives me an iostream error??
Was This Post Helpful? 0
  • +
  • -

#5 horace   User is offline

  • D.I.C Lover
  • member icon

Reputation: 768
  • View blog
  • Posts: 3,832
  • Joined: 25-October 06

Re: C++ Syntax Program Help

Posted 06 December 2006 - 01:41 AM

View Postaction, on 6 Dec, 2006 - 05:51 AM, said:

when i go to compile that it gives me an iostream error??

if you are using an old compiler (such as Turbo C V2 or V3) it may use the deprecated form of header. Try replacing
#include <iostream>

using namespace std;


with
#include <iostream.h>


This post has been edited by horace: 06 December 2006 - 01:42 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1