Skip to main content
corrected the code according to specification
Source Link
Abel Tom
  • 1.2k
  • 1
  • 7
  • 9

C 126126 121 bytes

f(){i=0;char c[]="/-|\\";for\\|";for(;i<101;i++){printf("\rloading %c %d %% ",c[rand()%4]c[i%4],i);fflush(stdout);usleep(1000*(rand()%75));}

Ungolfed version:

 void f()
 {
  int i=0;
  char c[]="/-|\\";\\|";
  for(;i<101;i++)
  {
    printf("\rloading %c %d %% ",c[rand()%4]c[i%4], i);
    fflush(stdout);
    usleep(1000*(rand()%75));  
  }
 } 

@Carcigenicate @ Mukul Kumar Did not read between the lines there, Thanks! :)

C 126 bytes

f(){i=0;char c[]="/-|\\";for(;i<101;i++){printf("\rloading %c %d %% ",c[rand()%4],i);fflush(stdout);usleep(1000*(rand()%75));}

Ungolfed version:

 void f()
 {
  int i=0;
  char c[]="/-|\\";
  for(;i<101;i++)
  {
    printf("\rloading %c %d %% ",c[rand()%4], i);
    fflush(stdout);
    usleep(1000*(rand()%75));  
  }
 } 

C 126 121 bytes

f(){i=0;char c[]="/-\\|";for(;i<101;i++){printf("\rloading %c %d %% ",c[i%4],i);fflush(stdout);usleep(1000*(rand()%75));}

Ungolfed version:

 void f()
 {
  int i=0;
  char c[]="/-\\|";
  for(;i<101;i++)
  {
    printf("\rloading %c %d %% ",c[i%4], i);
    fflush(stdout);
    usleep(1000*(rand()%75));  
  }
 } 

@Carcigenicate @ Mukul Kumar Did not read between the lines there, Thanks! :)

Source Link
Abel Tom
  • 1.2k
  • 1
  • 7
  • 9

C 126 bytes

f(){i=0;char c[]="/-|\\";for(;i<101;i++){printf("\rloading %c %d %% ",c[rand()%4],i);fflush(stdout);usleep(1000*(rand()%75));}

Ungolfed version:

 void f()
 {
  int i=0;
  char c[]="/-|\\";
  for(;i<101;i++)
  {
    printf("\rloading %c %d %% ",c[rand()%4], i);
    fflush(stdout);
    usleep(1000*(rand()%75));  
  }
 }