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);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.