Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
Notice removed Draw attention by chux
Bounty Ended with Edward's answer chosen by chux
deleted 14 characters in body; edited tags
Source Link
200_success
  • 144.2k
  • 22
  • 188
  • 473
#include "GPrint.h"
#include <limits.h>

int main(void) {
  double q = 1000000.0 / 7;
  int i = 42;
  GPrintf("42 --> base 10:", GP(i), 
      GP_setbase(2), " 2:", GP(i), 
      GP_setbase(36), " 36:", GP(i), GP_eol);

  GPrintf("million/7 = ", GP(q), GP_eol);
  GPrintf("million/7 = ", GP_setprecision(3), GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP_setprecision(3), GP(q), GP_eol);

  for (int y = 1; y < 9; y++) {
    int x = y * y;
    GPrintf(GP_setw(2), GP(y), ",", GP(x), ":", NULL);
    GPrintf(GP_repeat(x), GP((char)'*'), GP_eol);
  }
  GPrintf(GP_setw(5), GP(" "), ":", NULL);
  for (int x = 0; x < 70; x += 5)
    GPrintf("----+", NULL);
  GPrintf(GP_eol);

  return 0;
}
`main.c`
#include "GPrint.h"
#include <limits.h>

int main(void) {
  double q = 1000000.0 / 7;
  int i = 42;
  GPrintf("42 --> base 10:", GP(i), 
      GP_setbase(2), " 2:", GP(i), 
      GP_setbase(36), " 36:", GP(i), GP_eol);

  GPrintf("million/7 = ", GP(q), GP_eol);
  GPrintf("million/7 = ", GP_setprecision(3), GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP_setprecision(3), GP(q), GP_eol);

  for (int y = 1; y < 9; y++) {
    int x = y * y;
    GPrintf(GP_setw(2), GP(y), ",", GP(x), ":", NULL);
    GPrintf(GP_repeat(x), GP((char)'*'), GP_eol);
  }
  GPrintf(GP_setw(5), GP(" "), ":", NULL);
  for (int x = 0; x < 70; x += 5)
    GPrintf("----+", NULL);
  GPrintf(GP_eol);

  return 0;
}
`main.c`
#include "GPrint.h"
#include <limits.h>

int main(void) {
  double q = 1000000.0 / 7;
  int i = 42;
  GPrintf("42 --> base 10:", GP(i), 
      GP_setbase(2), " 2:", GP(i), 
      GP_setbase(36), " 36:", GP(i), GP_eol);

  GPrintf("million/7 = ", GP(q), GP_eol);
  GPrintf("million/7 = ", GP_setprecision(3), GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP(q), GP_eol);
  GPrintf("million/7 = ", GP_fixed, GP_setprecision(3), GP(q), GP_eol);

  for (int y = 1; y < 9; y++) {
    int x = y * y;
    GPrintf(GP_setw(2), GP(y), ",", GP(x), ":", NULL);
    GPrintf(GP_repeat(x), GP((char)'*'), GP_eol);
  }
  GPrintf(GP_setw(5), GP(" "), ":", NULL);
  for (int x = 0; x < 70; x += 5)
    GPrintf("----+", NULL);
  GPrintf(GP_eol);

  return 0;
}
Tweeted twitter.com/StackCodeReview/status/711041744008249344
Notice added Draw attention by chux
Bounty Started worth 100 reputation by chux
deleted 16 characters in body
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92
Source Link
chux
  • 33.6k
  • 2
  • 38
  • 92
Loading