Download
game show n.
Skip this Video
Loading SlideShow in 5 Seconds..
Game Show! PowerPoint Presentation

Game Show!

135 Views Download Presentation
Download Presentation

Game Show!

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Game Show! Cs 141 Exam 1 Review

  2. Cs 141 Exam 1 Review • What type/types hold the following: • 'a' • '\n' • '4'

  3. Cs 141 Exam 1 Review • What type/types hold the following: • 0,1,-1,2,-2,...

  4. Cs 141 Exam 1 Review • What is the main difference between the values that can be stored in an int variable and the set of all integers that you learned about in math?

  5. Cs 141 Exam 1 Review • What type/types hold the following: 0,1,2,3,4,...

  6. Cs 141 Exam 1 Review • What type/types could be legitimately substituted for TYPE TYPE foo = 4;

  7. Cs 141 Exam 1 Review • What is the main difference between a float and a double?

  8. Cs 141 Exam 1 Review • int bar = 23/4; • What is bar?

  9. Cs 141 Exam 1 Review • int foo = 23%4; • What is foo?

  10. Cs 141 Exam 1 Review • float bop = 23/4; • What is bop?

  11. Cs 141 Exam 1 Review • int baz; • What is the value of baz?

  12. Cs 141 Exam 1 Review • What are three ways to initialize the value of a variable?

  13. Cs 141 Exam 1 Review • What would happen if you did this: • const int foo = 5; • foo = 10;

  14. Cs 141 Exam 1 Review • Is this a valid comment? • /* Written by Jeanna

  15. Cs 141 Exam 1 Review • Is this a valid comment? • \\ Written by Jeanna

  16. Cs 141 Exam 1 Review • What are two ways to write a valid comment?

  17. Cs 141 Exam 1 Review • Declare a variable to hold someone's last name.

  18. Cs 141 Exam 1 Review • Declare a variable to hold someone's age in years.

  19. Cs 141 Exam 1 Review • Declare a variable to hold someone's hourly wage.

  20. Cs 141 Exam 1 Review • Declare a variable to hold someone's middle initial.

  21. Cs 141 Exam 1 Review • If you wanted to declare a variable to keep track of the number of times someone blinks in a year, what would be a good choice for the type and why?

  22. Cs 141 Exam 1 Review What does != mean?

  23. Cs 141 Exam 1 Review • What is the difference between = and ==?

  24. Cs 141 Exam 1 Review • What does && mean?

  25. Cs 141 Exam 1 Review • What does || mean?

  26. Cs 141 Exam 1 Review • What is the difference between: cin >> foo; cout << foo;

  27. Cs 141 Exam 1 Review • Which of these lines is not like the others? foo++; ++foo; foo+=1; foo = foo +1; foo+1;

  28. Cs 141 Exam 1 Review • What is wrong with this? if ((answer == ‘y’) | (answer == ‘Y’)){ cout << “User entered yes\n”; }

  29. Cs 141 Exam 1 Review • What is wrong with this? if ((answer == ‘y’) && (answer == ‘Y’)){ cout << “User entered yes\n”; }

  30. Cs 141 Exam 1 Review • What will happen if you do this? • num =3; • if (num =2){ • cout << “Number is 2\n”; • } else { • cout << “Number is not 2\n”; • }

  31. Cs 141 Exam 1 Review • What will happen if you do this • num =3; • if (num !=2){ • cout << “Number is not 2\n”; • } else if (num < 4) { • cout << “Number is less than 4\n”; • } else if (num >0){ • cout << “Number is greater than 0\n”; • }

  32. Cs 141 Exam 1 Review • What is the value of BAZ below? enum SillyNames {FOO=1, BAR, BAZ};

  33. Cs 141 Exam 1 Review • Declare an enum of the days of the week.

  34. Cs 141 Exam 1 Review • What is the advantage of declaring an enum?

  35. Cs 141 Exam 1 Review • Are these two boolean expressions the same? (x >=10) ((x ==10) && (x > 10))

  36. Cs 141 Exam 1 Review • There are 3 different types of clauses in an if statement: if, else if and else • How many of each can you have?

  37. Cs 141 Exam 1 Review • Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions total =0; i=0; while (i< 10){ total = total +i; i++; } cout << total;

  38. Cs 141 Exam 1 Review • Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions for(i=0; i< 10; i++){ total = total +i; } cout << total;

  39. Cs 141 Exam 1 Review • Identify the following in this loop: InitializationActions, LoopCondition, UpdateActions, BodyStatements, CompletionActions howMany=0; while(input_stream >> num){ howMany++; total = total + num; } average = total/howMany;

  40. Cs 141 Exam 1 Review • If homMany and total are ints, what problem will be have computing average? What could we do to fix the problem? What type should average be? howMany=0; while(input_stream >> num){ howMany++; total = total + num; } average = total/howMany;

  41. Cs 141 Exam 1 Review int numbers[3]; How many ints are declared? How would you refer to the first one? The last one? Write a for loop to add them all up

  42. Cs 141 Exam 1 Review int numbers[3][2]; How many ints are declared? How would you refer to first one? How would you refer to the last one? Write a for loop to add them all up.

  43. Cs 141 Exam 1 Review • If you want to read from or write to a file what must you add to our basic template?

  44. Cs 141 Exam 1 Review #include <fstream>

  45. Cs 141 Exam 1 Review • Declare a variable to hold a file you want to read from

  46. Cs 141 Exam 1 Review ifstream input_file;

  47. Cs 141 Exam 1 Review • Declare a variable to hold a file you want to write to.

  48. Cs 141 Exam 1 Review ofstream output_file;

  49. Cs 141 Exam 1 Review How would you open the file “foo.txt”?

  50. Cs 141 Exam 1 Review fileVariable.open(“foo.txt”);