Test run of the five programs presented in this chapter:
The following are valid variable names:
Int
Calloc
floating
ReInitialize
Xx
_1312
_
alpha_beta_routine
z
The following are not valid variable names:
char // a keyword describing a type in C
6_05 // variablnames are not allowed to start with a digit
A$ // character used in variable names can only be a-z, A-Z, 0-9 or _
The last variable is not a valid name because of the dollar sign. It should however be noted that this variable name can often be used anyway. This is because of compiler extensions that extends the original C standard.
The following are invalid constants:
0996 invalid digit "9" in octal constant
0x10.5 hexadecimal floating constants require an exponent
98.7U invalid suffix "U" on floating constant
1.2Fe-7 invalid suffix "Fe-7" on floating constant
0X0G1 invalid suffix "G1" on integer constant
1777s invalid suffix "s" on integer constant
Program that converts 27 degrees Fahrenheit to Celsius:
The expected output from the program in this exercise is:
d = d
Program for that evaluates a polynomial:
Program that evaluates an expression with exponential numbers:
Nothing to do in this exercise. But contains instructions on how to calculate the next largest even multiple of another integer. This is useful to know when solving the next exercise.
Program that finds the next largest even multiple for some pairs of sample data: