Table of Contents
Intro to Programming Teaching Assistant --- week3
Agenda
Converting between different number systems
Writing simple c codes
Using the less obvious features of printf(like width field and precision)
Notes
-
Why is the exponent in ieee format stored as an unsigned int instead of in 2’s complement.
$ \ $
-
Valid variable names
- Had n’t known that just an _ was a valid variable name in C
- Read this C variable naming rules - C Programming - c4learn.com
$ \ $
-
Evaluating expressions in printf
$ \ $
-
Using width field, precision in printf
The value of the field width or precision can be specified as a separate parameter like so:
printf("%*d*", 3, my_var)
Here 3 represents the value of the width field
- Read this
$ \ $
-
Having to link math.h while compiling
Even after specifying math.h as #include, the way to make the code work properly is to do this:
$ gcc my_file.c -lm
-
Reason
Read this
-