boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

00174.c (1146B)


      1 #include <stdio.h>
      2 #include <math.h>
      3 
      4 int main()
      5 {
      6    // variables
      7    float a = 12.34 + 56.78;
      8    printf("%f\n", a);
      9 
     10    // infix operators
     11    printf("%f\n", 12.34 + 56.78);
     12    printf("%f\n", 12.34 - 56.78);
     13    printf("%f\n", 12.34 * 56.78);
     14    printf("%f\n", 12.34 / 56.78);
     15 
     16    // comparison operators
     17    printf("%d %d %d %d %d %d\n", 12.34 < 56.78, 12.34 <= 56.78, 12.34 == 56.78, 12.34 >= 56.78, 12.34 > 56.78, 12.34 != 56.78);
     18    printf("%d %d %d %d %d %d\n", 12.34 < 12.34, 12.34 <= 12.34, 12.34 == 12.34, 12.34 >= 12.34, 12.34 > 12.34, 12.34 != 12.34);
     19    printf("%d %d %d %d %d %d\n", 56.78 < 12.34, 56.78 <= 12.34, 56.78 == 12.34, 56.78 >= 12.34, 56.78 > 12.34, 56.78 != 12.34);
     20 
     21    // assignment operators
     22    a = 12.34;
     23    a += 56.78;
     24    printf("%f\n", a);
     25 
     26    a = 12.34;
     27    a -= 56.78;
     28    printf("%f\n", a);
     29 
     30    a = 12.34;
     31    a *= 56.78;
     32    printf("%f\n", a);
     33 
     34    a = 12.34;
     35    a /= 56.78;
     36    printf("%f\n", a);
     37 
     38    // prefix operators
     39    printf("%f\n", +12.34);
     40    printf("%f\n", -12.34);
     41 
     42    // type coercion
     43    a = 2;
     44    printf("%f\n", a);
     45    printf("%f\n", sin(2));
     46 
     47    return 0;
     48 }
     49 
     50 /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/