[Skip Breadcrumb Navigation]
:
[Skip Breadcrumb Navigation]
Home
Student Resources
Quizzes
Chapter 1
Chapter 1
C++ Basics
This activity contains 10 questions.
Which of the following is a valid name for an identifier?
_foobar_2
2fast
interest rate
cout
What data types can be used to store numeric values with a decimal point, such as 3.14 ?
long
float, double
char
short, int
Which of the following statements will correctly output the quote:
Dan Quayle once said, "Who's responsible for the riots? The rioters."
cout << "Dan Quayle once said, Who's responsible for the riots? The rioters.";
cout << "Dan Quayle once said, \"Who's responsible for the riots? The rioters. \" ";
cout << "Dan Quayle once said, "Who's responsible for the riots? The rioters. " ";
cout << "Dan Quayle once said, "Who\'s responsible for the riots? The rioters.
" "
;
What value is stored in variable x?
int x;
x = 2 * 3 + 4 * 5 -- 4 / 2;
23
11
14
28
What value is stored in x after the following two statements are executed:
int x;
x = 2 / 4 * 4 / 2;
1
1.0
0.0625
0
Runners often think of their speed in terms of how many minutes and seconds it takes to run a mile, but most treadmills express speed in miles per hour. Which expression correctly converts from 6.5 miles per hour to output the pace in minutes and seconds?
int secsPerMile = static_cast<int<(3600 / 6.5);
int paceMins, paceSecs;
paceMins = secsPerMile / 60;
paceSecs = paceMin % 60;
int secsPerMile = static_cast<int<(3600 / 6.5);
int paceMins, paceSecs;
paceMins = secsPerMile / 60;
paceSecs = secsPerMile / 60 / 60;
int secsPerMile = static_cast<int<(3600 * 6.5);
int paceMins, paceSecs;
paceMins = secsPerMile / 60;
paceSecs = secsPerMile % 60;
int secsPerMile = static_cast<int<(3600 / 6.5);
int paceMins, paceSecs;
paceMins = secsPerMile / 60;
paceSecs = secsPerMile % 60;
What will the following code output?
int x, y;
x=3;
y=(++x)*2;
cout << x << " " << y << endl;
3 6
3 8
4 8
4 6
How can we input a value from the keyboard and store it in the variable named num?
cout << num;
cin << num;
num = input();
cin >> num;
Which of the following is an invalid comment?
/**************************
* Comment about the program
**************************/
// Comment regarding the program
/* Comment regarding the program
*/
/* Comment regarding the program
For a newer C++ compiler, what must be added to the top of the program to allow access to cin and cout?
#include <iostream.h>
using namespace std;
#include <iostream>
using namespace std;
using namespace std;
#include <iostream.h>
The Submit Answers for Grading feature requires scripting to function. Your browser either does not support scripting or you have turned scripting off.
So, the Submit Answers for Grading button below will not work.
The following Submit Answers for Grading button is provided in its place and will clear your answers:
The Clear Answers and Start Over feature requires scripting to function. Your browser either does not support scripting or you have turned scripting off.
So, the Clear Answers and Start Over button below will not work.
The following Clear Answers button is provided in its place and will clear your answers:
Your browser either does not support scripting or you have turned scripting off. Because of this, the answer choices will NOT appear in a different order each time the page is loaded, though that is mentioned below. Note that you do not need this feature to use this site.
Answer choices in this exercise appear in a different order each time the page
is loaded.
Copyright © 1995 - 2010
Pearson Education
. All rights reserved. Pearson Addison Wesley is an imprint of
Pearson
.
Legal Notice
|
Privacy Policy
|
Permissions
[Return to the Top of this Page]
: [Return to the Top of this Page]