Help newbie in c++ here

Is there any way for me to run the program again without exiting, like it just resets.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
using namespace std;
int main()
{
	system("color F0");
std::cout<<"PROJECT IN C++"<<std::endl;
    int squareHeight, squareWidth;
    cout<< "Enter Height:  ";
    cin>>  squareHeight;
    cout<< "Enter Widht:   ";
    cin>>  squareWidth;
  for(int width=1; width<=squareHeight; width++)
    {
   if(width <= 1)
   for(int width=1; width<=squareWidth; width++)
            {
                cout<< "@";
            }
        else if(width<squareHeight)
        {
            cout<< endl;
for(int width2=1; width2<=squareWidth; width2++)
      {
      if(width2==1 || width2==squareWidth)
                    cout<< "@";
                else
                    cout<< " ";
            } 
        }
        else
        {
            cout<< endl;
for(int width3=1; width3<=squareWidth; width3++)
   {
                cout<<"@";
            }
        }
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>

int main()
{
    std::cout<<"PROJECT IN C++\n" ;

    char run_again ;

    do
    {
        int height, width;
        std::cout << "Enter Height:  ";
        std::cin >>  height;
        std::cout << "Enter Width:   ";
        std::cin >>  width;

        // minimum 3x3 square
        if( height < 3 ) height = 3 ;
        if( width < 3 ) width = 3 ;

        const char border_char = '@' ;

        // print the top line (all border characters)
        for( int i = 0 ; i < width ; ++i ) std::cout << border_char ;
        std::cout << '\n' ;

        // print the middle height-2 lines
        for( int i = 0 ; i < (height-2) ; ++i )
        {
            std::cout << border_char ; // a border character at the left

            // then, width-2 spaces in the middle
            for( int j = 0 ; j < (width-2) ; ++j ) std::cout << ' ' ;

            std::cout << border_char << '\n' ; // border and a new line at the end
        }

        // print the bottom line (all border characters)
        for( int i = 0 ; i < width ; ++i ) std::cout << border_char ;
        std::cout << '\n' ;

        std::cout << "run again (y/n)? " ;
        std::cin >> run_again ;

    } while( run_again == 'y' || run_again == 'Y' ) ;
}
thanks a lot.
Topic archived. No new replies allowed.