Study questions for Lecture Test 1 CS 115

Not complete but good to work on! These will not be collected, but you can certainly discuss them with your classmates or your TA or Dr. Keen.

  1. Do you know the difference between input and output, the difference between RAM and a hard drive, and what is a path? What's the difference between a text file and an exe file?
  2. Name as many C++ libraries as you can, and list the functions or operations from each that you use.
  3. Write down three legal identifiers. Can you state why each one is legal? Try to use all the rules of identifier creation. Write three invalid identifiers; make each one invalid in a different way.
  4. What does 'case sensitive' mean?
  5. How do you declare a variable? Where do you declare a variable? Why do you declare a variable? How do you initialize a variable? How do you declare a global variable?
  6. What happens when you declare a variable?
  7. How do you declare a named constant? Where do you declare it? Why do you declare it?
  8. What's the difference between a named constant and a variable? What are the similarities?
  9. What's special about the main function?
  10. Write an assignment statement that has the formula below stored in a variable called result. Use no more parentheses than needed.
    		  a  + b  -  4 e - f      
    
    2 a
  11. Trace this code: Mark statements which contain type coercion. Rewrite the statements so they use type casting.
    		float v1, v2;
    		int v3;
    
    		v1 = 15.7;
    		v3 = 3 * 9.2;
    		v2 = v1 + v3;
    		v3 = v2 - 15;
    		v1 = 17;
    		v2 = 3 * v1;
    
  12. Trace this code: Remember that means to show RAM and output areas.
    	int a, b, c, x, y;
    	
    	b = 7;
    	x = 5;
    	y = x * 15;
    	cout << b << x << y;
    	a = 3 * b + 9;
    	x = y + 3;
    	y = x;
    	cout << b << x << a << y;
    	a = 5 * b;
    
  13. Calculate the values of the expressions. Indicate what type the answer is.
    	a.  5 + 4 * (3.2 + 4.5)
    	b.  7 % 5 + 12 / 7
    	c.  8 + pow( 4.0, 3)
    
  14. Trace this code:
    	int x = 7;
    	cout  << " x " << x << endl << endl << endl << "*****" << "endl"
    		<< endl << endl;
    	cin >> x; 	// assume the user types 23 and presses enter
    	cout << "  x " << x << endl;
    
  15. Describe how a compiler works. What jobs does it do for you? what will it not do for you?
  16. Alice uses objects and methods and functions. Can you tell the difference between them? What's an event? What's an instance?
  17. What is the value of a and b after this code?
    	float y = 2.3;
    	int a, b;
    	a = (int) y * 2;
    	b = y / 2;
    	
    
  18. Write a complete program that performs the interaction given. The user enters a number of dollars and the program tells how many pennies that is. Use at least one variable and one named constant.
  19. Name the properties of a variable (or piece of data), the four that we discussed in class.
  20. What's the difference between syntax and semantics? How do you find syntax errors? semantics errors?
  21. Describe John von Neumann's contribution to computers. Why is it important to today's computers?
  22. List the parts of the IDE that you have used so far. What did you use each one for?
  23. We used Alice to illustrate the control structures of structured programming. What are they and how do they work? can you name a data structure or two?
  24. What is "dead code"? What is an "infinite loop"? What is "spaghetti code"?
  25. Comments - how do you write them? why do you write them? who reads them?
  26. Name the different data types in C++. How are they different? what are they used for? What do constants of each type look like?
  27. Who is Bjarne Stroustrup? Dennis Ritchie?
  28. Why do we care about the C++ language standard?
  29. Describe precisely the actions that happen when an assignment statement is executed. That is, what happens first? second? last?
  30. Name some pre-written functions. What type do they require for arguments? what type do they return?
  31. Show the output of this code.
    	x = 19;
    	if (x > 15)
    		cout << "blue";
    	else
    		cout << "white";
    	if (x < 7)
    		cout << "green";
    	cout << "red";
    
  32. Describe a 'single step'. Where do you use it?
  33. Describe pseudocode. When is it written?