I hav this code below.How can i use Macros , so that i can change at random "-" and " " without searching through the codes?

#include <iostream>

using namespace std;

int main()
{
   int row,col,n;
   cout<<"Enter an Integer number:\n";
   cin>> n;

   cout<<("Numerical Pattern\n");
   for ( row = 1 ; row <=n ; row++ )
   {
   for ( col=1; col <= row ; col++ )
   {
      if(col==row)
      {
         cout<<"-";
   }
      else
      {
         cout<<" ";
      }
   }

    cout<<endl;   
   }

    return(EXIT_SUCCESS);

}
#include <iostream>

using namespace std;

#define PATTERN   "-"
#define SEPARATOR " "

int main()
{
   int row,col,n;
   cout<<"Enter an Integer number:\n";
   cin>> n;

   cout<<("Numerical Pattern\n");
   for ( row = 1 ; row <=n ; row++ )
   {
       for ( col=1; col <= row ; col++ )
       {
          if(col==row)
          {
             cout<< PATTERN;
          }
          else
          {
             cout<< SEPARATOR;
          }
       }

       cout<<endl;   
   }

   return(EXIT_SUCCESS);
}
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.