/* * programming_types_vars_consts.c * * Created on: Mar 14, 2023 * Author: johnsontimoj */ //////////////////////////////////////////////// // // Program to practice some programming concepts // // inputs: none // outputs: some printed statements // //////////////////////////////////////////// // our included libraries #include // provides access to printf() and scanf() // a defined constant #define PI 3.14159 // start our main function // format is taken on faith for now // everything between the { } is part of main int main(void){ setbuf(stdout, NULL); // fixes a console bug in eclipse windows // this is taken on faith for now // splash printf("-----------------------------------------\n"); printf("This is my program to practice types, vars and constants\n"); printf("-----------------------------------------\n"); printf("\n"); // create a few variables int int_var; float float_var; char char_var; // memory constant const int INT_CONST = 13; // print them - should be garbage // combining printf() statements on a single line (no \n) printf("%i", int_var); // 1 var print printf("%f", float_var); // printf("%c", char_var); // printf("%i\n", INT_CONST); // initialize our variables int_var = 12; float_var = 3.45; char_var = 'g'; // force failure by trying to change a memory constant // INT_CONST = 4; // print them again printf("%i %f %c\n", int_var, float_var, char_var); // multiple var print // use the defined constant float_var = PI; printf("%f\n", float_var); // printf("%i\n", INT_CONST); // print our values - this time with text // char_val with the %c format prints the character, with the %i format prints the ascii value printf("int_var is: %i, float_var = %f, and char_var is the character %c with ascii value: %i\n", int_var, float_var, char_var, char_var); // multiple var print // finish up printf("All done!"); // finish our main function with a return for the operating system return 0; }// end main