source: examples/square.c @ 7cfd6d4

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 7cfd6d4 was 200fcb3, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

add auto newline to sout, change endl to nl

  • Property mode set to 100644
File size: 1.5 KB
Line 
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//
7// square.c --
8//
9// Author           : Richard C. Bilson
10// Created On       : Wed May 27 17:56:53 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Dec 11 23:28:24 2018
13// Update Count     : 28
14//
15
16#include <fstream.hfa>
17
18forall( otype T | { T ?*?( T, T ); } )
19T square( T t ) {
20        return t * t;
21} // square
22
23int main() {
24#if 0
25        sout | "result of squaring 9 is ";
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;
32        sout | "char\t\t\t" | square( c );
33
34        sout | square( s );
35#endif
36        short s = 9;
37        square( s );
38#if 0
39        signed int i = 9;
40        sout | "signed int\t\t" | square( i );
41
42        unsigned int ui = 9;
43        sout | "unsigned int\t\t" | square( ui );
44
45        long int li = 9;
46        sout | "signed long int\t\t" | square( li );
47
48        unsigned long int uli = 9;
49        sout | "unsigned long int\t" | square( uli );
50
51        signed long long int lli = 9;
52        sout | "signed long long int\t" | square( lli );
53
54        unsigned long long int ulli = 9;
55        sout | "unsigned long long int\t" | square( ulli );
56
57        float f = 9.0;
58        sout | "float\t\t\t" | square( f );
59
60        double d = 9.0;
61        sout | "double\t\t\t" | square( d );
62
63        long double ld = 9.0;
64        sout | "long double\t\t" | square( ld );
65#endif
66} // main
67
68// Local Variables: //
69// tab-width: 4 //
70// compile-command: "cfa square.c" //
71// End: //
Note: See TracBrowser for help on using the repository browser.