// file: /data/courses/ece_1111/lectures/current/lecture_06/example.cc // // local include files // #include "example.h" // function: main // // This is a simple program that prints to the terminal. // int main(int argc, const char** argv) { // print the program name // fprintf(stdout, "program name: %s\n", argv[0]); // logical variable // //bool flag = false; // bool flag_t = true; //int sz_1 = sizeof(bool); //int sz_2 = sizeof(flag_t); //fprintf(stdout, "(size: %d) value = %d\n", sz_1, flag); // fprintf(stdout, "(size: %d) value = %d\n", sz_2, flag_t); // char // char a = 'J'; // fprintf(stdout, "the value of a is %c (%d)\n", a, a); //unsigned char b = 3; //int sz = sizeof(unsigned char); //fprintf(stdout, "the value of b is %u (%d)\n", b, sz); //char c = -1; //fprintf(stdout, "the value of c is %d\n", c); short int s = 3; int sz = sizeof(unsigned char); //fprintf(stdout, "the value of s is %d (%d)\n", s, sz); 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 = JOES_NUMBER; //x = x / pow(10, 9); int sz_f = sizeof(float); int sz_d = sizeof(double); //fprintf(stdout, "the value of x is %f (%d %d)\n", x, sz_f, sz_d); 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); //unsigned int i = atoi(argv[1]); //fprintf(stdout, "i = %f (%s)\n", i, argv[1]); // declare an unsigned char - one byte // //float x; //fprintf(stdout, "%fd: %f\n", x, x); unsigned char foo, goo, fsoso, j; //for (long i = 0; i < 257; i++) { //foo = i; //fprintf(stdout, "%d: %d\n", i, foo); // } // declare a signed character - ASCII // //char c; //for (long i = -128; i < 128; i++) { //c = i; //fprintf(stdout, "%d: %c (%d)\n", i, c, c); //} // declare a 16-bit integer // //short s; // unsigned short us; //for (long i = -32768; i < 32768; i++) { //s = i; //fprintf(stdout, "%d: %d (%d)\n", i, s, s); // } // declare an "int" integer // // int k; // unsigned int uk; // for (int i = -pow(2,31); i < pow(2,31); i++) { // k = i; // fprintf(stdout, "%d: %d (%d)\n", k, k, k); // } // declare long integer // // long l; // unsigned long ul; // for (long i = -2^63; i < 2^63 - 1; i++) { // s = i; // fprintf(stdout, "%d: %d (%d)\n", i, s, s); // } // declare a floating-point number // // float x = 27.00125; //fprintf(stdout, "x = %f\n", x); // declare a double precision floating-point number // // double y = 27.00125; //fprintf(stdout, "y = %f\n", y); // declare a character string // // char* joe = (char*)"Joe"; // fprintf(stdout, "joe = %s\n", joe); // declare a boolean value // // bool b = true; // bool bb = false; // exit gracefully // return(0); }