Skip to content

Latest commit

 

History

History
65 lines (57 loc) · 2.13 KB

Chapter_03.md

File metadata and controls

65 lines (57 loc) · 2.13 KB

Exercise Solutions Chapter 3

1.

Test run of the five programs presented in this chapter:

2.

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.

3.

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  

4.

Program that converts 27 degrees Fahrenheit to Celsius:

5.

The expected output from the program in this exercise is:

d = d  

6.

Program for that evaluates a polynomial:

7.

Program that evaluates an expression with exponential numbers:

8.

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.

9.

Program that finds the next largest even multiple for some pairs of sample data: