Corning Community College
C/C++ Programming
\\
End of Course Experience
~~TOC~~
======Rules======
Presented within will be various questions evaluating your knowledge and experience gained this semester. In places where you are able, the more you write and explain topics the better the chance you will have of receiving full credit (and alternatively, the more credit you will receive should something be incorrect).
The questions on this experience are open resource with the exception of other individuals. In that respect, it is CLOSED PERSON. This means you are not to communicate with other people (either in the class or otherwise), in real life or electronically. Use your own knowledge, use your skills, and use your ability to access the allowed resources to aid you in coming up with your well thought out answers to each question.
You are allowed, and expected, to ask me questions, so that a problem can be better clarified.
You are to do **all** questions. Submission is to be in an organized and easy to read format in a plain text file, such as in an e-mail with attachments on Lab46, sent to **wedge@lab46.corning-cc.edu** and yourself.
You have until 11:59:59pm (that's 23:59:59 in 24-hour time) Wednesday, May 18th, 2011 to complete and submit this to me.
Although do have a scheduled finals week meeting time (Tuesday, May 17th, 2011 from 11:15am-2:15pm), you are also welcome to come to the BDC, Room **B003** for questions on:
* Tuesday, May 17th from 8am-2:15pm
* Wednesday, May 18th from 11:15am-2:15pm
Good luck!
======Questions======
=====0x0: Debug=====
Analyze the following code:
printf("a: %d\n", a);
printf("b: %d\n", b);
if (a = b)
; // do nothing
else
a = a ^ b; // else do this
b = a ^ b; // and this
a = a ^ b; // and this
printf("a: %d\n", a);
printf("b: %d\n", b);
Answer me the following:
* Complete the program, submit your fully working version to me with this EoCE
* There are two instances of unintended program logic errors in the above snippet. What are they?
* How does the code behave with the logical errors that are present?
* What does the code, when corrected, actually do? What algorithmic purpose does it serve?
=====0x1: Identification=====
Looking at the following code snippet:
int i;
for(i=0; i<10; i++)
{
printf("%d\n", (i * i));
}
Answer me the following:
* Is this code C code, C++ code, or some other language/combination? (And if so, what?)
* How did you determine this?
=====0x2: Analysis=====
Analyze the following program:
#include
int main()
{
int i, j = 1;
for(i=1; i<=255; i=i<<1)
{
j = j * 3;
}
return(0);
}
And tell me:
* What is the program doing?
* How many times does the **for** loop iterate?
* What is the logic behind this particular for loop's iteration?
* What is the value of **j** upon completion of the for loop?
=====0x3: Classes of Color and Overloading=====
In C++, write a **Color** class that accomplishes the following:
* Has the following **Public:** member functions:
* Color() constructor
* Color(string) parametered constructor that accepts a string color
* display() accessor method that returns the string of the current color
* overload the **+** operator to allow the addition of two Color class instances
* overload the **-** operator to allow the subtraction of two Color class instances
* Has the following **Private:** member functions:
* value: an integer that corresponds to the current color
* shade: a string that corresponds to the current color
To "add" or "subtract" colors, look to actual color combinations:
* Red, Yellow, and Blue are primary colors
* Orange, Green, and Purple are secondary colors
* White is the presence of all colors
* Black is the absence of all colors
Might there be some mathematical relationship between the colors, so that we can apply numerical values to aid us in our processing?
=====0x4: Colors in motion=====
With the completion of your Color class, write a small application program (ie a **main()**) that instantiates a few Color objects.
With this program, do the following:
* Instantiate at least 3 color objects
* Set two of them to various colors
* Add two colors together, and store the result in the third color
* Subtract two colors, and store the result in another color
* Display the colors going into various operations, and the resulting color after the operation has taken place.
=====0x5: Collision=====
In "Shoveling Bob" we have the main player, which occupies a position on the screen.
There are to be a few opponents also located on the screen, with their respective coordinates.
During gameplay, there are interactions that take place between the player and opponents. For this to take place, our game logic needs to detect when a "collision" takes place. A collision is when the edge of one object intersects with another.
In our game, we'll use the 32x32 square box as the boundaries of the object. This facilitates the task of detecting collisions:
* The left edge of one object has a fixed X value, and a range of Y values. This left edge can only collide with right edges of other objects.
* Similarly, right edges intersect with foreign left edges.
* Top edges interact with bottom edges, and have a fixed Y with a range of X.
* Finally, bottom edges collide with top edges.
Considering 3 objects on the screen (one player, two opponents), write some logic that will check to see if any collisions between the player and the two opponents has taken place.
=====0x6: Definitions=====
Please define, and provide small (but complete) programs that demonstrate the following concepts:
* if/else if/else statement
* do-while loop
* pass by value function
* pass by address/reference function
* array
* pointer
=====0x7: Programs=====
Write small C/C++ programs that accomplish the following:
* Prompt user for temperature in fahrenheit degrees. Convert that temperature to Celcius and Kelvin degrees, and display both as output to the user.
* Read 8 values into an array. Calculate and display their average, median, mode, and range.
=====0x8: Your Perspective=====
After an exciting and intellectually challenging run, we're arriving at the end of this semester's journey. The course as we all experienced it, unfolds in a manner pertaining in part to how you respond to concepts and topics (do we need more time, can I crank it up a couple notches, etc.) so each semester and each class is entirely different from any other- because of each of you, and all of us, working together and learning together.
So, searching deep down within your soul- balancing reason with emotion, and considering attendance and timeliness; answer me the following:
* What grade do you feel you deserve for this course?
* Why do you feel you deserve this mark? (Justify your answer based on your own perceived performance, not on need.)
* How did you feel about the course?
* Was it useful/interesting to you?
* What was your least favorite aspect, and why?
* What was something meaningful to you with respect to the course? Why does this stick out in your mind?
* Any other comments or suggestions?
======Submission======
When done, compose an e-mail to me with your responses to the various questions. There is no electronic submission form for the EoCE.
Be sure your e-mail is organized and easy to read!