Need help to print grids of letters
..for example

ABABA
BABAB
ABABA
BABAB
ABABA
BABAB

so when row and column numbers are the same (r == c) the program prints an A.
Any clue as to how I should approach this problem will be appreciated?

this is what i got so far..

#include <iostream>
using namespace std;

int main ()
{
     int n;
     cout << endl << "Enter a positive integer: ";
     cin >> n;
     while (n < 0)
     {
         exit (1);
     }
     for (int r = 1; r <= n; r++)
     {
         for (int c = 1; c <= n; c++)
         {
             if      (r == c)                    cout << "A";
             else if (What should i put here)    cout << "?";
             else if (What should i put here)    cout << "?";
         }
         cout << endl;
     }
        return 0;
}

Edited 4 Years Ago by bdl365

Solved!

#include <iostream>
using namespace std;

int main ()
{
    int n;
    cout << endl << "Enter a positive integer: ";
    cin >> n;
    while (n < 0)
    {
        exit (1);
    }
    for (int r = 1; r <= n; r++)
    {
        for (int c = 1; c <= n; c++)
        {
            if      (r % 2 != 0 && c % 2 !=0)    cout << "A";
            else if (r % 2 != 0 && c % 2 == 0)   cout << "B";
            else if (r % 2 == 0 && c % 2 == 0)   cout << "A";
            else if (r % 2 == 0 && c % 2 != 0)   cout << "B";
        }
        cout << endl;
    }
    return 0;
}

Edited 4 Years Ago by bdl365

This question has already been answered. Start a new discussion instead.