1.4 Errors and warnings (All Questions)
An experienced programmer writes 80 lines of code, and then compiles and runs. The programmer is probably _____ . 1. programming dangerously 2. following good practice
1
A new programmer writes 5 lines of code, compiles and runs, writes 5 more lines, and compiles and runs again. The programmer is _____ . 1. wasting time 2. following good practice
2
A compiler generates the following error messages: Line 7: Missing semicolon Line 9: numItems not defined Line 10: Expected '(' If the programmer does NOT find an error on line 7, the programmer should check line _______.
6
A compiler generates the following error messages: Line 7: Missing semicolon Line 9: numItems not defined Line 10: Expected '(' The programmer should start by examining line _______.
7
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout << "Dogs: " numDogs;
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout < "Everyone wins.";
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout << "Hello friends! << "\n";
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout << NumDogs << "\n";
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout << numDogs.
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout >> numDogs >> "\n";
Error
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? int numCats numCats = 3; cout << numCats << "\n";
Error
True or False? A compiler warning by default will prevent a program from being created.
False
True or False? A compiler's default settings cause most warnings to be reported during compilation.
False
True or False? If a compiler generates a specific message like "missing semicolon", then a semicolon must be missing somewhere, though maybe from an earlier line.
False
True or False? If a compiler says that an error exists on line 90, the actual error may be on line 91, 92, etc.
False
True or False? When a compiler says that an error exists on line 5, that line must have an error.
False
Find the syntax errors. Assume variable numDogs has been declared. Error or No Error? cout << Amy // Michael" << "\n";
No error
True or False? Generally, a programmer should not ignore warnings.
True
A compiler generates the following error messages: Line 7: Missing semicolon Line 9: numItems not defined Line 10: Expected '(' If the programmer finds an error on line 7, the programmer should ______.
compile
Type the statements below and correct the one syntax error in each. cout << "Num: " << songnum << endl; cout << int songNum << endl; cout << songNum " songs" << endl;
cout << "Num: " << songNum << endl; cout << songNum << endl; cout << songNum << " songs" << endl;
Type the statements below and correct the one syntax error in each. cout << "Predictions are hard." << end; cout << "Especially '; cout << "about the future." << endl. cout << "Num is: " << userNum >> endl;
cout << "Predictions are hard." << endl; cout << "Especially"; cout << "about the future/" << endl; cout << "Num is: " << userNum << endl;