diff --git a/pset1/2-stdio.c b/pset1/2-stdio.c index bdc2449..a659589 100644 --- a/pset1/2-stdio.c +++ b/pset1/2-stdio.c @@ -1,16 +1,16 @@ #include -int main(void) -{ - //initialization - char sex; - int age; - float height; +int main(void) { + // initialization + char sex; + int age; + float height; - //get input from stdin - scanf("%c %i %f", &sex, &age, &height); - - //print answer to stdout - printf("The sex is %c, the age is %i, and the height is %f.", sex, age, height); - return 0; + // get input from stdin + scanf("%c %i %f", &sex, &age, &height); + + // print answer to stdout + printf("The sex is %c, the age is %i, and the height is %f.", sex, age, + height); + return 0; } diff --git a/pset1/5-data-types.c b/pset1/5-data-types.c index d71cfe0..675c843 100644 --- a/pset1/5-data-types.c +++ b/pset1/5-data-types.c @@ -1,27 +1,27 @@ #include -int main(void) -{ - //initialize variables - char a; - short b; - int c; - long d; - long long e; - float f; - double g; +int main(void) { + // initialize variables + char a; + short b; + int c; + long d; + long long e; + float f; + double g; - //assign values from stdin - scanf ("%c %hd %i %ld %lld %f %lf", &a, &b, &c, &d, &e, &f, &g); + // assign values from stdin + scanf("%c %hd %i %ld %lld %f %lf", &a, &b, &c, &d, &e, &f, &g); - //print answers - printf("The 'char' variable is %c, it takes %ld byte.\n", a, sizeof(a)); - printf("The 'short' variable is %hd, it takes %ld bytes.\n", b, sizeof(b)); - printf("The 'int' variable is %i, it takes %ld bytes.\n", c, sizeof(c)); - printf("The 'long' variable is %ld, it takes %ld bytes.\n", d, sizeof(d)); - printf("The 'long long' variable is %lld, it takes %ld bytes.\n", e, sizeof(e)); - printf("The 'float' variable is %f, it takes %ld bytes.\n", f, sizeof(f)); - printf("The 'double' variable is %lf, it takes %ld bytes.\n", g, sizeof(g)); + // print answers + printf("The 'char' variable is %c, it takes %ld byte.\n", a, sizeof(a)); + printf("The 'short' variable is %hd, it takes %ld bytes.\n", b, sizeof(b)); + printf("The 'int' variable is %i, it takes %ld bytes.\n", c, sizeof(c)); + printf("The 'long' variable is %ld, it takes %ld bytes.\n", d, sizeof(d)); + printf("The 'long long' variable is %lld, it takes %ld bytes.\n", e, + sizeof(e)); + printf("The 'float' variable is %f, it takes %ld bytes.\n", f, sizeof(f)); + printf("The 'double' variable is %lf, it takes %ld bytes.\n", g, sizeof(g)); - return 0; + return 0; }