source: src/examples/square.c @ 0ada2f0

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 0ada2f0 was 784deab, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

fix recursive include bug in shadow includes, major clean of examples, add several long long routines to prelude

  • Property mode set to 100644
File size: 1.6 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 Jan  5 18:08:20 2016
13// Update Count     : 21
14//
15
16#include "fstream.h"
17
18forall( type T | { T ?*?( T, T ); } )
19T square( T t ) {
20        return t * t;
21} // square
22
23int main() {
24#if 0
25        ofstream *sout = ofstream_stdout();
26        sout | "result of squaring 9 is " | endl;
27
28        // char does not have multiplication.
29        char ?*?( char a1, char a2 ) {
30                return (char)((int)a1 * (int)a2);
31        } // ?*?
32        char c = 9;
33        sout | "char\t\t\t" | square( c ) | endl;
34
35        sout | square( s ) | endl;
36#endif
37        short int s = 9;
38        square( s );
39#if 0
40        signed int i = 9;
41        sout | "signed int\t\t" | square( i ) | endl;
42
43        unsigned int ui = 9;
44        sout | "unsigned int\t\t" | square( ui ) | endl;
45
46        long int li = 9;
47        sout | "signed long int\t\t" | square( li ) | endl;
48
49        unsigned long int uli = 9;
50        sout | "unsigned long int\t" | square( uli ) | endl;
51
52        signed long long int lli = 9;
53        sout | "signed long long int\t" | square( lli ) | endl;
54
55        unsigned long long int ulli = 9;
56        sout | "unsigned long long int\t" | square( ulli ) | endl;
57
58        float f = 9.0;
59        sout | "float\t\t\t" | square( f ) | endl;
60
61        double d = 9.0;
62        sout | "double\t\t\t" | square( d ) | endl;
63
64        long double ld = 9.0;
65        sout | "long double\t\t" | square( ld ) | endl;
66#endif
67} // main
68
69// Local Variables: //
70// tab-width: 4 //
71// compile-command: "cfa square.c fstream.o iostream.o iterator.o" //
72// End: //
Note: See TracBrowser for help on using the repository browser.