box-o-sand/oldstuff/lcthw-remnants/ex7.c

37 lines
1.0 KiB
C
Raw Normal View History

2011-09-06 00:50:39 +00:00
#include <stdio.h>
int main(int argc, char *argv[])
{
int bugs = 100;
double bug_rate = 1.2;
printf("You have %d bugs imaginary rate of %f.\n",
bugs, bug_rate);
unsigned long universe_of_defects = 63.99999999999 * 32 * 1024 * 1024;
2011-09-06 00:50:39 +00:00
printf("The entire universe has %ld bugs.\n",
universe_of_defects);
double expected_bugs = bugs * bug_rate;
printf("You are expected to have %f bugs.\n",
expected_bugs);
double part_of_universe = expected_bugs / universe_of_defects;
printf("That is only a %e portion of the universe.\n",
part_of_universe);
// this makes no sense, just a demo of something weird
2011-09-06 00:50:39 +00:00
char nul_byte = '\0';
int care_percentage = bugs * nul_byte;
printf("Which means you should care %d%%.\n",
care_percentage);
2011-09-06 01:03:40 +00:00
puts("also...");
int nul = (int)nul_byte;
int *nul_ptr = &nul;
printf("char '\\0' = '%c', (int)'\\0' = '%d', &(int)'\\0' = '%n'.\n",
nul_byte, nul, nul_ptr);
2011-09-06 00:50:39 +00:00
return 0;
}