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

Assume the availability of a function called printStars. The function receives a

ID: 3759100 • Letter: A

Question

Assume the availability of a function called printStars. The function receives an int  argument . If the argument is positive, the function prints (to standard output ) the given number of asterisks. Thus, if the printStars(8) is called, ******** (8 asterisks) will be printed.

Assume further that the variable  starCount has been declared and initialized to a some integer , possibly negative or zero.

Write some code that does nothing if starCount is not positive but that otherwise prints starCount asterisks to standard output by:

first printing a single asterisk (and no other characters )

then calls printStars to print the remaining asterisks.

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

Explanation / Answer

Answer :

#include <stdio.h>

void printStars(int number);

int main() {
int n ;
printf ( " Enter number to display asterisk's ");
scanf ( "%d", &n ) ;
   if(n==0)
   printf("please enter a positive number to proceed");
   else
   printStars(n);

   return 0;
}
void printStars(int number)
{
int starCount=0;
   for(int i=0;i<number;i++){//used to print out rows
starCount++;
//used to print asterisk in each row
printf("%s","*");

}
printf("%d",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