Home
1.
Explain the difference between a source code file, object code file, and executable file.

A source code file contains code as written in whatever language the programmer is using. An object code file contains machine language code; it need not be the code for a complete program. An executable file contains the complete code, in machine language, constituting an executable program.

2.
What are the seven major steps in programming?

a. Defining program objectives.
b. Designing the program.
c. Coding the program.
d. Compiling the program.
e. Running the program.
f. Testing and debugging the program.
g. Maintaining and modifying the program.

3.
What are the basic modules of a C program called?

They are called functions.

4.
What is a semantic error? Give an example of one in English and one in C. ?

A semantic error is one of meaning. Here’s an example in English: "This sentence is excellent Czech." Here's a C example:
thrice_n = 3 + n;

5.
How would you print the values of the variables words and lines so they appear in the following form:
There were 3020 words and 350 lines.
Here, 3020 and 350 represent the values of the two variables.

printf("There were %d words and %d lines.\n", words, lines);

6.
Why would you use a type long variable instead of type int ?

One reason is that long may accommodate larger numbers than int on your system; another reason is that if you do need to handle larger values, you improve portability by using a type guaranteed to be at least 32 bits on all systems.

7.
What portable types might you use to get a 32-bit signed integer, and what would the rationale be for each choice?

To get exactly 32 bits, you could use int32_t , provided it was defined for your system. To get the smallest type that could store at least 32 bits, use int_least32_t . And to get the type that would provide the fastest computations for 32 bits, choose int_fast32_t .

8.
What is whitespace?

Whitespace consists of spaces, tabs, and newlines. C uses whitespace to separate tokens from one another; scanf() uses whitespace to separate consecutive input items from each other.

9.
What's wrong with the following statement and how can you fix it?
printf("The double type is %z bytes..\n", sizeof (double));

The z in %z is a modifier, not a specifier, so it requires a specifier for it to modify. You could use %zd to print the result in base 10 or use a different specifier to print using a different base, for example, %zx for hexadecimal.

10.
Suppose that you would rather use parentheses than braces in your programs. How well would the following work?
#define ( {
#define ) }

The substitutions would take place. Unfortunately, the preprocessor cannot discriminate between those parentheses that should be replaced with braces and those that should not. Therefore,

#define ( {
#define ) }
int main(void)
(
printf("Hello, O Great One!\n");
)
becomes
int main{void}
{
printf{"Hello, O Great One!\n"};
}