source:
tests/zombies/square.c
@
a46f7b6
Last change on this file since a46f7b6 was fd54fef, checked in by , 4 years ago | |
---|---|
|
|
File size: 1.5 KB |
Rev | Line | |
---|---|---|
[86bd7c1f] | 1 | // |
2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | |
3 | // | |
4 | // The contents of this file are covered under the licence agreement in the | |
5 | // file "LICENCE" distributed with Cforall. | |
6 | // | |
[73abe95] | 7 | // square.c -- |
[86bd7c1f] | 8 | // |
9 | // Author : Richard C. Bilson | |
10 | // Created On : Wed May 27 17:56:53 2015 | |
11 | // Last Modified By : Peter A. Buhr | |
[200fcb3] | 12 | // Last Modified On : Tue Dec 11 23:28:24 2018 |
13 | // Update Count : 28 | |
[86bd7c1f] | 14 | // |
15 | ||
[73abe95] | 16 | #include <fstream.hfa> |
[a0d9f94] | 17 | |
[fd54fef] | 18 | forall( T | { T ?*?( T, T ); } ) |
[a0d9f94] | 19 | T square( T t ) { |
[86bd7c1f] | 20 | return t * t; |
[784deab] | 21 | } // square |
[86bd7c1f] | 22 | |
[a0d9f94] | 23 | int main() { |
[784deab] | 24 | #if 0 |
[200fcb3] | 25 | sout | "result of squaring 9 is "; |
[784deab] | 26 | |
27 | // char does not have multiplication. | |
28 | char ?*?( char a1, char a2 ) { | |
29 | return (char)((int)a1 * (int)a2); | |
30 | } // ?*? | |
31 | char c = 9; | |
[200fcb3] | 32 | sout | "char\t\t\t" | square( c ); |
[784deab] | 33 | |
[200fcb3] | 34 | sout | square( s ); |
[784deab] | 35 | #endif |
[d3b7937] | 36 | short s = 9; |
[784deab] | 37 | square( s ); |
38 | #if 0 | |
39 | signed int i = 9; | |
[200fcb3] | 40 | sout | "signed int\t\t" | square( i ); |
[784deab] | 41 | |
42 | unsigned int ui = 9; | |
[200fcb3] | 43 | sout | "unsigned int\t\t" | square( ui ); |
[784deab] | 44 | |
45 | long int li = 9; | |
[200fcb3] | 46 | sout | "signed long int\t\t" | square( li ); |
[784deab] | 47 | |
48 | unsigned long int uli = 9; | |
[200fcb3] | 49 | sout | "unsigned long int\t" | square( uli ); |
[784deab] | 50 | |
51 | signed long long int lli = 9; | |
[200fcb3] | 52 | sout | "signed long long int\t" | square( lli ); |
[784deab] | 53 | |
54 | unsigned long long int ulli = 9; | |
[200fcb3] | 55 | sout | "unsigned long long int\t" | square( ulli ); |
[784deab] | 56 | |
57 | float f = 9.0; | |
[200fcb3] | 58 | sout | "float\t\t\t" | square( f ); |
[784deab] | 59 | |
60 | double d = 9.0; | |
[200fcb3] | 61 | sout | "double\t\t\t" | square( d ); |
[784deab] | 62 | |
63 | long double ld = 9.0; | |
[200fcb3] | 64 | sout | "long double\t\t" | square( ld ); |
[784deab] | 65 | #endif |
66 | } // main | |
[86bd7c1f] | 67 | |
68 | // Local Variables: // | |
69 | // tab-width: 4 // | |
[d3b7937] | 70 | // compile-command: "cfa square.c" // |
[86bd7c1f] | 71 | // End: // |
Note: See TracBrowser
for help on using the repository browser.