Skip to content

Instantly share code, notes, and snippets.

@boxmein
Last active December 25, 2015 09:29
Show Gist options
  • Save boxmein/6954339 to your computer and use it in GitHub Desktop.
Save boxmein/6954339 to your computer and use it in GitHub Desktop.
A script that demonstrates integer division in C. Prints two numbers, the first with integer division and the second with floating division. Integer division is achieved by having the divisor be an integer.
/*
A script that demonstrates integer division in C.
Prints two numbers, the first with integer division
and the second with floating division.
Integer division is achieved by having the divisor
be an integer.
Compile with anything really. Running produces the
following output:
0 0.333333
*/
#include <stdio.h>
int main(int argc, char **argv) {
printf("%d ", 1/3);
printf("%f\n", 1.0f/3.0f);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment