program that asks the user to input width and height and prints a checkerboard of 3-by-3 squares.

0 votes
asked Feb 23, 2018 by anonymous 1 flag
(It should work even if the input dimensions are not a multiple of three.)

1 Answer

0 votes
answered Aug 18, 2018 by Ethan Alexander Lee (580 points)
C++ Program
```

#include <iostream>
using namespace std;

void printChecker(int width, int height, char character){
    for(int a=0;a<height;a++){
        if (a%2 == 0)
            cout<<" ";
        for(int b=0;b<width;b++){
            if (b%2 == 0)
                    cout<<character;
            else cout<<" ";
        }
        cout<<endl;
    }
    return;
}

int main(){
    char character = '#';
    int width=3,height=3;
    
    cout<<"Enter Width: ";
    cin>>width;
    cout<<"Enter height: ";
    cin>>height;
    
    cout<<endl;
    
    printChecker(width,height,character);
    
    cout<<endl<<"Thanks for using this program"<<endl;
    return 0;
}
```
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...