I need a c program that does the following Lets get some pra

I need a c++ program that does the following:

Let\'s get some practice in writing simple functions, and a challenge in nested repetition. Follow the provided steps to produce a custom checkerboard on the screen:

Define a global symbolic constant MaxWidth to be 40, and MaxHeight to be MaxWidth/2

Create a main program to display a rectangle with MaxHeight rows and MaxWidth columns of alternating \'.\' and \'*\' characters. They must alternate across each row, as well as down each column.

Modify your program so that all code is placed into the function checkerboard(). This function accepts an input integer argument width and does not return anything. (The argument is just ignored at this time.)

Create getWidth() that accepts a single integer pass by reference argument. It prompts the user for an integer in the range of 1 to MaxWidth and stores it in the provided argument. Re-prompt the user until a valid value is given. This function does not have a return value.

(Bonus) Check the failbit to verify a valid integer has been input in getWidth().

Modify the main program to first call getWidth(), then call checkerboard() passing the width obtained by getWidth().

Make sure to compile and link your program to make sure everything is still working fine.

(Bonus) Modify checkerboard() to use the input parameter. Instead of single alternating \'.\' and \'*\' characters, you will produce width characters at a time, making larger squares. As before, you are also producing alternating squares vertically.

For instance, your final output if the user enters 3 for width will appear as:

ty Dis for funct sted repetitious objectives creating functions, pass by value and reference, nested repetition Let\'s get some practice in writing simple functions, and a challenge in nested repetition Follow the provided steps to produce a custom checkerboard on the screen 1. Define a global symbolic constant Maxwidth to be 10, and ght to be NaxNidth/2 2. reate a main program to display a rectangle with MaxHeieht rows and Maxwidth columns of altemating and characters They must altermate across each row, as well as down each column 3. Modify your program so that all code is placed into the function checkerboerd(). This function accepts an input integer argument width and does not return anything. The argument is just ignored at this time.) M. Create getwidth() that accepts a single in pass by reference argument. It prompts the user for ari integer in the range of 1 to Maxwidth and stores it in the provided argument Re prompt the user until a valid value is given. This function does not have a re 5. (Bonus) Check the failbit to verify a valid integer has been input in Ectwidth() 6 Modify the main program to first call dth then call board sing the width obtained by get Kidth r. Make sure to comple and link your program to make sur Cverything is still ng hnc 8 (Ronus) Modify checkerboard to use the input parameter Instead of single alternating and characters, you will produce width characters at a time, making larger squares As before, you are also producing alternating squares vertically 9. For instance, your final output if the user enters 3 tor width will appcar as

Solution

checker.cpp:(Source Code)

#include<iostream.h>

#include<conio.h>

const int maxWidth= 40;

const int maxHeight = maxWidth/2;

void getWidth(int*);

void checkerboard(int);

int main(){

int width;

clrscr();

getWidth(&width);

checkerboard(width);

getch();

return 0;

}

void getWidth(int *w){

int temp=0;

do{

cout<<\"Enter width in between 1 to maxWidth:\";

cin>>temp;

*w = temp;

}while(temp>40);

}

void checkerboard(int w){

for(int i=0;i<maxHeight;i++){

int total = 0, flag = 1;

for(int j=0;j<maxWidth;j = j+ w){

if(flag){

int count = 0;

while(count<w && total<maxWidth){

cout<<\".\";

total++;

count++;

}

flag = 0;

}

else{

int count = 0 ;

while(count<w && total < maxWidth){

cout<<\"*\";

total++;

count++;

}

flag = 1;

}

}

cout<<\"\ \";

}

}

Sample Input & Output :

Enter Width in between 1 to maxWidth: 3

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

***...***...***...***...***...***...***.

...***...***...***...***...***...***...*

...***...***...***...***...***...***...*

I need a c++ program that does the following: Let\'s get some practice in writing simple functions, and a challenge in nested repetition. Follow the provided st
I need a c++ program that does the following: Let\'s get some practice in writing simple functions, and a challenge in nested repetition. Follow the provided st
I need a c++ program that does the following: Let\'s get some practice in writing simple functions, and a challenge in nested repetition. Follow the provided st

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site