pre2 - Prelab Exercises Sections 2.3 - 2.4 1. What is the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Prelab Exercises Sections 2.3 - 2.4 1. What is the difference between a variable and a constant? A variable is an identifier that refers to a memory location used to hold data values that can change as the program executes. A constant, on the other hand, is an identifier that holds a data value that cannot change. 2. Explain what each of the lines below does. Be sure to indicate how each is different from the others. a. int x; Declares a variable named x that will hold an integer value (type int). Memory is allocated for the variable but the value is undefined. b. int x = 3; Declares a variable named x that will hold a value of type int and stores the initial value of 3 in the variable. c. x = 3; Stores the value of 3 in the variable x. 3. The following program reads three integers and prints the average. Fill in the blanks so that it will work correctly. // ******************************************************************* // Average.java // // Read three integers from the user and print their average
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/22/2010 for the course CS 202 taught by Professor Fong during the Spring '10 term at SIU Carbondale.

Page1 / 4

pre2 - Prelab Exercises Sections 2.3 - 2.4 1. What is the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online