ECE-1011 (SPRING 2003)

QUIZ #1 PREP SHEET

 

(p24) What are the five steps in the Problem Solving Methodology presented in the text for this course?

  1. _________________________________
  2. _________________________________
  3. _________________________________
  4. _________________________________
  5. _________________________________

(p41) What is the purpose of the #include preprocessor directive?

(p41) What characters are used to identify the beginning and ending of comments in a C program?

(p41) What is the required name for the primary function in your program?

(p41) What are the two types of commands that are contained in a function?

(p41) How can initial values be assigned to variables at the time they are declared?

(p41) What can be said about the values of variables that are not initialized?

(p41) What type of commands define the memory locations to be used within that function and associate a name with each?

(p42) What type of commands specify the operations that the function is to perform?

(p42) What character is used to identify the ends of commands in a C program?

(p43) What is the general form of a C program?

(p44) What are the rules for valid variable identifiers (variable names)?

(p45) This distance from the Earth to the Sun is approximately 93 million miles. Declare a variable of type double named "AstroUnit" and initialize it to this value using exponential notation.

(p47) Using a typical compiler, it is discovered that the following code fragment:

float x1 = 10000000;

x1 = x1 + 1;

results in the value stored in x1 being unchanged. What is the most likely cause of this problem?

(p48) The ASCII code associated with a lower case letter is always 32 greater than the code associated with an upper case letter. The ASCII code for the letter A is 65 (in decimal). The ASCII codes increase as the associated characters increase in alphabetical order - i.e., the ASCII code for Z is greater than the ASCII code for A. What value is stored in the following declaration?

int a = ('z' - 'A');  /* Notice: 'z' and not 'Z' */

(p49) Write the definition statement for a symbolic constant for PI that satisfies the Style Guidelines for this course with respect to the use of parentheses in symbolic constant definition statements.

(p53) What value is stored in the following statement?

k = 25 / 10 * 10;

(p54) What operator has the highest precedence and should therefore be liberally used in order to unambiguously establish the order in which all other operators will be evaluated within a statement?

(p55) What is the difference between the pre-increment and post-increment operators?

(p56) Which of the following statements will not have the same effects as all of the others? Why not?

int i = 10, k;

  1. k = i++;
  2. k = ++i; k--;
  3. k = i; i++;
  4. k = i++ - 1;
  5. k = -1 + (i += 1);

(p60) Which standard library file must be included in order to use printf()?

(p60) In a printf() statement, conversion specifiers begin with what character?

(p62) What conversion specifier would be used to print out a value of type double such that it occupies a total of six spaces and has 3 digits to the right of the decimal point?

(p62) Explain what each character in the following conversion specifier means: "%+-6.1f"

(p62) If a backslash character is encountered in the format string of a printf() statement, what happens if the next character is a 'n'?

(p62) How do you print out a percent sign in a format string?

 

Write a complete C program that prints, "Hello World!" to the screen including the quotation marks.

 

An annular ring can be thought of as a circular peice of material with a smaller and concentric circular hole in it. An example is a common flat washer. Consider the following program:

#define PI (3.1415926)

#define INNER (10.0)

#define OUTER (12.0)

int main(void)

{

   double area;

   /* Assignment statement for 'area' goes here. */

   printf("The area is %f square units.\n", area);

   return(0);

}

Write the assignment statement that should replace the comment above to generate the correct value for the area of the annular ring.