// file: lecture_06/example.cc // // This file demonstrates some simple atomic types in C/C++ used // to do engineering mathematics. // // local include files // #include "example.h" // method: main // // A simple driver program to demonstrate numeric representations. // int main(int argc, char** argv) { // print the program name // fprintf(stdout, "program name: %s\n", argv[0]); // logical variable // bool flag = false; fprintf(stdout, "the value of flag is %d\n", flag); // char // char a = 'J'; fprintf(stdout, "the value of a is %c\n", a); unsigned char b = 3; fprintf(stdout, "the value of b is %d\n", b); char c = -1; fprintf(stdout, "the value of c is %d\n", c); short int s = -32768; fprintf(stdout, "the value of s is %d\n", s); unsigned short int t = 65535; fprintf(stdout, "the value of t is %u\n", t); signed int i = pow(2,31) - 1; fprintf(stdout, "the value of i is %u\n", i); float joe = JOES_NUMBER; // float x = 27.2727272727; // double x = 3e-37; x = x / pow(10, 9); fprintf(stdout, "the value of x is %e\n", x); double y = 27.2727272727; fprintf(stdout, "the value of y is %f\n", y); float v = 27.2727272727; fprintf(stdout, "the value of v is %f\n", v); float z = M_PI; fprintf(stdout, "the value of z is %15.4e\n", z); // exit gracefully // return(0); }