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

I do not know how to do this please help Write a program that walks an ‘*’ to th

ID: 3625626 • Letter: I

Question

I do not know how to do this please help

Write a program that walks an ‘*’ to the right and back to the left exactly like this demonstration. The first thing your program should do is ask the user how far to walk. You will write functions and not put the movement code in main. Your main function must look like this:
int main() { int x;
printf("Enter how far to walk. "); scanf("%i", &x); // add some checking to see if x is <=1 or >10
goThereAndBack(x); goStraightThereAndBack(x); // * stays on the same line
} Hints: Pause 1 second: sleep(1); Move backward 1 space: printf(“%c”, ‘’); Flush the output buffer and print my printf statement now: fflush(stdout);

Explanation / Answer

please rate - thanks

without the demo I can;t be sure this is correct

#include <stdio.h>
void goThereAndBack(int);
void goStraightThereAndBack(int);
int main()
{ int x;
printf("Enter how far to walk. ");
scanf("%i", &x); // add some checking to see if x is <=1 or >10
goThereAndBack(x);
goStraightThereAndBack(x); // * stays on the same line
}
void goThereAndBack(int x)
{int i,j;
for(i=0;i<=x;i++)
    {for(j=0;j<i;j++)
         printf("");
    for(j=0;j<i;j++)
         printf(" ");
    printf("*");
    sleep(1000);
    fflush(stdout);
   
    }
for(i=0;i<=x;i++)
    {
    printf("");
      printf(" ");
      printf("");
      printf("");
     printf("*");
    sleep(1000);
    fflush(stdout);
    }
}
void goStraightThereAndBack(int x)
{int i,j;
printf("");
for(j=0;j<x;j++)
   printf(" ");
printf("*");
sleep(1000);
fflush(stdout);
printf("");
printf(" ");
for(j=0;j<=x;j++)
    printf("");
printf("*");
fflush(stdout);

}

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