ADT
        aaron-thesis
        arm-eh
        ast-experimental
        cleanup-dtors
        deferred_resn
        demangler
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        new-env
        no_list
        persistent-indexer
        pthread-emulation
        qualifiedEnum
        resolv-new
        with_gc
      
      
        
          | Last change
 on this file since bd098ea was             b63e376, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago | 
        
          | 
update refrat with new keywords, update examples, update separators for quoted strings
 | 
        
          | 
              
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 Mar  8 22:05:48 2016 | 
|---|
| 13 | // Update Count     : 27 | 
|---|
| 14 | // | 
|---|
| 15 |  | 
|---|
| 16 | #include <fstream> | 
|---|
| 17 |  | 
|---|
| 18 | forall( otype T | { T ?*?( T, T ); } ) | 
|---|
| 19 | T square( T t ) { | 
|---|
| 20 | return t * t; | 
|---|
| 21 | } // square | 
|---|
| 22 |  | 
|---|
| 23 | int main() { | 
|---|
| 24 | #if 0 | 
|---|
| 25 | sout | "result of squaring 9 is " | endl; | 
|---|
| 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 ) | endl; | 
|---|
| 33 |  | 
|---|
| 34 | sout | square( s ) | endl; | 
|---|
| 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 ) | endl; | 
|---|
| 41 |  | 
|---|
| 42 | unsigned int ui = 9; | 
|---|
| 43 | sout | "unsigned int\t\t" | square( ui ) | endl; | 
|---|
| 44 |  | 
|---|
| 45 | long int li = 9; | 
|---|
| 46 | sout | "signed long int\t\t" | square( li ) | endl; | 
|---|
| 47 |  | 
|---|
| 48 | unsigned long int uli = 9; | 
|---|
| 49 | sout | "unsigned long int\t" | square( uli ) | endl; | 
|---|
| 50 |  | 
|---|
| 51 | signed long long int lli = 9; | 
|---|
| 52 | sout | "signed long long int\t" | square( lli ) | endl; | 
|---|
| 53 |  | 
|---|
| 54 | unsigned long long int ulli = 9; | 
|---|
| 55 | sout | "unsigned long long int\t" | square( ulli ) | endl; | 
|---|
| 56 |  | 
|---|
| 57 | float f = 9.0; | 
|---|
| 58 | sout | "float\t\t\t" | square( f ) | endl; | 
|---|
| 59 |  | 
|---|
| 60 | double d = 9.0; | 
|---|
| 61 | sout | "double\t\t\t" | square( d ) | endl; | 
|---|
| 62 |  | 
|---|
| 63 | long double ld = 9.0; | 
|---|
| 64 | sout | "long double\t\t" | square( ld ) | endl; | 
|---|
| 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.