Arithmetic/Rational/C: Difference between revisions

m
Fixed syntax highlighting.
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
Line 1:
{{collection|Rational Arithmetic}}
 
C doesn't support classes, so a series of functions is provided that implmentsimplements the arithmetic of a rational class.
<langsyntaxhighlight lang="c">#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Line 241:
rzlt->denominator = abs(l->denominator); // should already be nonnegative
return rzlt;
}</langsyntaxhighlight>
Testing
<langsyntaxhighlight lang="c">void find_perfects()
{
int n, n2, k;
Line 312:
find_perfects();
return 0;
}</langsyntaxhighlight>
9,476

edits