Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a function called printStars. The function receives an int parameter . If

ID: 3759101 • Letter: W

Question

Write a function called printStars. The function receives an int  parameter . If the parameter is positive, the function prints (to standard output ) the given number of asterisks; otherwise the function does nothing. The function does not return a value . Thus, if the printStars(8) is called, ******** (8 asterisks) will be printed.

The function must not use a loop of any kind (for, while, do-while) to accomplish its job. Instead, it gets the job done by examining its parameter , returning if the parameter 's value is not positive. If the parameter is positive, it

prints a single asterisk (and no other characters )

then (recursively) calls itself to print the remaining asterisks.

can someone please help me write this code in c launguage.

Explanation / Answer

int i = 0;

void printStars(int starCount){

if(starCount>0){

if(i<starCount){

cout<<"*";

starCount;

i++;

printStars(starCount);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote