C++ Program "Draw Rectangle"

program prints the outline of a rectangle with 6 asterisks

Page 1 of 1

4 Replies - 18000 Views - Last Post: 13 October 2009 - 01:40 AM Rate Topic: -----

#1 Maverick420   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 13-October 09

C++ Program "Draw Rectangle"

Posted 13 October 2009 - 12:24 AM

I am trying to start this program I have some information regarding this please help me complete this program.

// This program prints the outline of a rectangle with 6 asterisks
// across and 8 asterisks down. 
// Input:  None
// Output: Prints the outline of the rectangle. 

#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char *argv[])
{								
   const int NUM_ACROSS = 6; 	// Number of asterisks to print across
   const int NUM_DOWN = 8;		// Number of asterisks to print down
   int row;	// Loop control for row number
   int column;	// Loop control for column number

   // Write a loop to control the number of rows
   // Write a loop to control the number of columns
	  
		 // Decide when to print an asterisk in every column
		 
			cout << "*";
		 // Decide when to print an asterisk in column 1 and column 6
		 
			cout << "*";
		 // Decide when to print a space instead of an asterisk
		 else
			cout << " "; 
	  // Figure out where to place this statement that prints a newline
	  cout << endl;
   }
   
   system("PAUSE");
   return EXIT_SUCCESS;
} // End of main()



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: C++ Program "Draw Rectangle"

#2 carltech   User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: C++ Program "Draw Rectangle"

Posted 13 October 2009 - 01:08 AM

I'll give you a hint: LOOP

look on the forums for this wxact problem and you will be able to find a solution. just search it
Was This Post Helpful? 0
  • +
  • -

#3 metalgirl   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 09-April 09

Re: C++ Program "Draw Rectangle"

Posted 13 October 2009 - 01:14 AM

:wank:

I think it would take you under 30 minutes even if you are completely new to this

take out yr arguements from yr main
like this... main()


where it says return EXIT_SUCCESS or whatever
change it to return 0;

Then if I were you I would:

// Write a loop to control the number of rows
// Write a loop to control the number of columns

// Decide when to print an asterisk in every column

cout << "*";
// Decide when to print an asterisk in column 1 and column 6

cout << "*";
// Decide when to print a space instead of an asterisk
else
cout << " ";
// Figure out where to place this statement that prints a newline

then you're done!
no need to thank me!
Was This Post Helpful? 0
  • +
  • -

#4 carltech   User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: C++ Program "Draw Rectangle"

Posted 13 October 2009 - 01:23 AM

it is unnecessary to take out the arguments to main or the EXIT_SUCCESS since they are pretty standard and will compile fine...so I won't thank you :) lolz
Was This Post Helpful? 0
  • +
  • -

#5 metalgirl   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 39
  • Joined: 09-April 09

Re: C++ Program "Draw Rectangle"

Posted 13 October 2009 - 01:40 AM

don't listen to him, I think he is an imposter!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1