Download presentation
Presentation is loading. Please wait.
Published byGertrude Young Modified over 9 years ago
1
Cs 141 Exam 1 Review1 Game Show!
2
Cs 141 Exam 1 Review2 What type/types hold the following: 'a' '\n' '4'
3
Cs 141 Exam 1 Review3 What type/types hold the following: 0,1,-1,2,-2,...
4
Cs 141 Exam 1 Review4 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 Review5 What type/types hold the following: 0,1,2,3,4,...
6
Cs 141 Exam 1 Review6 What type/types could be legitimately substituted for TYPE TYPE foo = 4;
7
Cs 141 Exam 1 Review7 What is the main difference between a float and a double?
8
Cs 141 Exam 1 Review8 int bar = 23/4; What is bar?
9
Cs 141 Exam 1 Review9 int foo = 23%4; What is foo?
10
Cs 141 Exam 1 Review10 float bop = 23/4; What is bop?
11
Cs 141 Exam 1 Review11 int baz; What is the value of baz?
12
Cs 141 Exam 1 Review12 What are three ways to initialize the value of a variable?
13
Cs 141 Exam 1 Review13 What would happen if you did this: const int foo = 5; foo = 10;
14
Cs 141 Exam 1 Review14 Is this a valid comment? /* Written by Jeanna
15
Cs 141 Exam 1 Review15 Is this a valid comment? \\ Written by Jeanna
16
Cs 141 Exam 1 Review16 What are two ways to write a valid comment?
17
Cs 141 Exam 1 Review17 Declare a variable to hold someone's last name.
18
Cs 141 Exam 1 Review18 Declare a variable to hold someone's age in years.
19
Cs 141 Exam 1 Review19 Declare a variable to hold someone's hourly wage.
20
Cs 141 Exam 1 Review20 Declare a variable to hold someone's middle initial.
21
Cs 141 Exam 1 Review21 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 Review22 What does != mean?
23
Cs 141 Exam 1 Review23 What is the difference between = and ==?
24
Cs 141 Exam 1 Review24 What does && mean?
25
Cs 141 Exam 1 Review25 What does || mean?
26
Cs 141 Exam 1 Review26 What is the difference between: cin >> foo; cout << foo;
27
Cs 141 Exam 1 Review27 Which of these lines is not like the others? foo++; ++foo; foo+=1; foo = foo +1; foo+1;
28
Cs 141 Exam 1 Review28 What is wrong with this? if ((answer == ‘y’) | (answer == ‘Y’)){ cout << “User entered yes\n”; }
29
Cs 141 Exam 1 Review29 What is wrong with this? if ((answer == ‘y’) && (answer == ‘Y’)){ cout << “User entered yes\n”; }
30
Cs 141 Exam 1 Review30 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 Review31 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 Review32 What is the value of BAZ below? enum SillyNames {FOO=1, BAR, BAZ};
33
Cs 141 Exam 1 Review33 Declare an enum of the days of the week.
34
Cs 141 Exam 1 Review34 What is the advantage of declaring an enum?
35
Cs 141 Exam 1 Review35 Are these two boolean expressions the same? (x >=10) ((x ==10) && (x > 10))
36
Cs 141 Exam 1 Review36 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 Review37 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 Review38 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 Review39 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 Review40 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 Review41 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 Review42 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 Review43 If you want to read from or write to a file what must you add to our basic template?
44
Cs 141 Exam 1 Review44 #include
45
Cs 141 Exam 1 Review45 Declare a variable to hold a file you want to read from
46
Cs 141 Exam 1 Review46 ifstream input_file;
47
Cs 141 Exam 1 Review47 Declare a variable to hold a file you want to write to.
48
Cs 141 Exam 1 Review48 ofstream output_file;
49
Cs 141 Exam 1 Review49 How would you open the file “foo.txt”?
50
Cs 141 Exam 1 Review50 fileVariable.open(“foo.txt”);
51
Cs 141 Exam 1 Review51 If you try to open a file, what type of error should you check for and how do you do that?
52
Cs 141 Exam 1 Review52 Check if weren't able to open the file fileVariable.open(“foo.txt”); if (fileVariable.fail()){ cout << “Couldn't open the file\n”; }
53
Cs 141 Exam 1 Review53 How would you open the file foo.txt?
54
Cs 141 Exam 1 Review54 What does it mean to have a if statement nested inside a loop?
55
Cs 141 Exam 1 Review55 What does it mean to have nested for loops? What are nested for loops especially good for?
56
Cs 141 Exam 1 Review56 True or false: There are some problems for which you must use a do-while loop. A while loop just won't work.
57
Cs 141 Exam 1 Review57 When is it generally better to use a do- while loop instead of a while loop?
58
Cs 141 Exam 1 Review58 When is it generally better to use a for loop instead of a while loop or do-while loop?
59
Cs 141 Exam 1 Review59 When you get a bunch of compiler errors which one should you fix first and why?
60
Cs 141 Exam 1 Review60 If you are trying to fix a specific compiler error, how can you figure out where the problem is?
61
Cs 141 Exam 1 Review61 What is a fence post error?
62
Cs 141 Exam 1 Review62 If you were going to test this loop what would be three great values of x to test? Why? cin >> x; for (int i=0; i< x; i++){ cout << i; }
63
Cs 141 Exam 1 Review63 Will these do the same thing? for (i=0; i< 3;i++ ) cout << i; for (i=0;i< 3 ){ cout << i; i++; }
64
Cs 141 Exam 1 Review64 Will these do the same thing? for (i=0; i< 3;i++ ) cout << i; i=0; while (i< 3 ) cout << i++;
65
Cs 141 Exam 1 Review65 What would you expect to happen if you did this int numArray[5]; numArray[5] = 100; cout << numArray[5];
66
Cs 141 Exam 1 Review66 Whats wrong with this int numArray[9]; for (int i=0; i<=9; i++){ numArray[i] = i; }
67
Cs 141 Exam 1 Review67 Do these all do the same thing? cout << num << “\n”; cout << num << endl; cout << num; cout << “\n”;
68
Cs 141 Exam 1 Review68 What child of a famous British poet is often considered the first programmer?
69
Cs 141 Exam 1 Review69 Ada Byron Lovelace (1815-1852)
70
Cs 141 Exam 1 Review70 Who is the creator of C++?
71
Cs 141 Exam 1 Review71 Bjarne Stroustrup
72
Cs 141 Exam 1 Review72 Who is the creator of the C programming language and a co-author of the UNIX operating system?
73
Cs 141 Exam 1 Review73 Dennis Ritchie
74
Cs 141 Exam 1 Review74 Explain the joke in the name C++
75
Cs 141 Exam 1 Review75 Who coined the term “debugging” and wrote the first compiler for a computer programming language?
76
Cs 141 Exam 1 Review76 Rear Admiral Grace Hopper
77
Cs 141 Exam 1 Review77 Picture of the moth that was the first computer “bug”
78
Cs 141 Exam 1 Review78 Who is this?
79
Cs 141 Exam 1 Review79 Linus Torvalds author and developer of Linux
80
Cs 141 Exam 1 Review80 Who is this?
81
Cs 141 Exam 1 Review81 Steve Jobs, co-founder and CEO of Apple Corporation
82
Cs 141 Exam 1 Review82 Who is this?
83
Cs 141 Exam 1 Review83 Steve Wozniak, co-founder of Apple Corporation
84
Cs 141 Exam 1 Review84 What does IBM stand for?
85
Cs 141 Exam 1 Review85 International Business Machines
86
Cs 141 Exam 1 Review86 Who is considered the founder of IBM?
87
Cs 141 Exam 1 Review87 Thomas J. Watson
88
Cs 141 Exam 1 Review88 Whats wrong with this function bool foo (int, double){ return true; }
89
Cs 141 Exam 1 Review89 Whats wrong with this function void doubleIt(int num){ num = 2* num; }
90
Cs 141 Exam 1 Review90 Whats wrong with this function int double bar(int num){ return num; }
91
Cs 141 Exam 1 Review91 Whats wrong with this function void doubleIt(int num){ return 2* num; }
92
Cs 141 Exam 1 Review92 void baz (int num1, int &num); Which is the call by value parameter and which is the call by reference parameter?
93
Cs 141 Exam 1 Review93 What does call by value mean?
94
Cs 141 Exam 1 Review94 What does call by reference mean?
95
Cs 141 Exam 1 Review95 void bar(int numArray[]){ } Is numArray call by value or call by reference?
96
Cs 141 Exam 1 Review96 What do you have to do to make an array parameter call by value?
97
Cs 141 Exam 1 Review97 What does procedural abstraction or information hiding or black box design mean?
98
Cs 141 Exam 1 Review98 What is the purpose of assertions?
99
Cs 141 Exam 1 Review99 How can you turn off assertions before you release code to users?
100
Cs 141 Exam 1 Review100 Why would you turn off assertions before you release code to users?
101
Cs 141 Exam 1 Review101 Give me an example of function overloading?
102
Cs 141 Exam 1 Review102 What is meant by a global variable?
103
Cs 141 Exam 1 Review103 Where are global variables declared?
104
Cs 141 Exam 1 Review104 What is the type of variable used for output files?
105
Cs 141 Exam 1 Review105 What is the type of variable used for input files?
106
Cs 141 Exam 1 Review106 How do you test if a file open succeeds?
107
Cs 141 Exam 1 Review107 How do you test if a file read or write succeeds?
108
Cs 141 Exam 1 Review108 How do you test if you read all the contents of a file?
109
Cs 141 Exam 1 Review109 What do you add to the file open call if you want to append to a file?
110
Cs 141 Exam 1 Review110 If I did this ./a.out inputFile.txt What would argc be?
111
Cs 141 Exam 1 Review111 If I did this ./a.out inputFile.txt What would argv[1] be?
112
Cs 141 Exam 1 Review112
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.