chapt 2

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

just before a program is processed by the compiler.

Preprocessor directives are carried out

2

Qualifying an integer declaration with "unsigned" essentially increases the maximum value of the variable by a factor of

#include <iostream> using namespace std; int main(){ cout << "Hello World "; return 0; }

Write a complete program that prints Hello World to the screen.

int hits;

Write a declaration for a variable hits that can hold the number of times a baseball player has hit the ball in a baseball game.

int age; int weight;

Write a declaration for two integer variables , age and weight.

int count;

Write a declaration of a variable named count that can be used to hold numbers like 90000 and -1 and -406.

int numberOfWidgets;

Write a declaration of a variable named numberOfWidgets that can be used to hold numbers like 57 and 981 and -4.

int number_of_children;

Write a declaration of a variable named number_of_children that can be used to hold the number of children in a family.

0xf

Write a hexadecimal integer literal representing the value fifteen.

0

Write a literal representing the integer value zero.

12000000L

Write a literal representing the long integer value twelve million.

37L

Write a long integer literal that has the value thirty-seven

int count;

Write a statement that declares an int variable named count.

cout << "Hello World";

Write a statement that prints Hello World to the screen.

cout<<"i=";

Write a statement that prints the following to standard output : i= Just write one statement that generates the message above: do not generate any extraneous spaces. Do not declare variables , do not write a main() function, do not write a whole program .

num = 4;

Write a statement to set the value of num to 4 (num is a variable that has already been declared ).

#include <iostream>

Write the include directive needed to allow use of the various I/O operators such as cout and cin.

#include<myFuncs.h>

Write the include directive that allows use of the function headers in the file myFuncs.h.

6

How many lines are printed out by this statement: cout << "abc\ndef\tghi\njkl" << endl << endl << "mno\npqr\n";

cout<<count;

Given an integer variable count, write a statement that writes the value of count to standard output .

drivingAge = 17;

Given an integer variable drivingAge that has already been declared , write a statement that assigns the value 17 to drivingAge.

can be anything the programmer wants to write.

The text of a comment

monthlyPay

Which is the best identifier for a variable to represent the amount of money your boss pays you each month?

main

Which of the following is NOT a C++ keyword?

None of the above

Which of the following names in a program is equivalent to the name int?

cout

Which of the following will not be recognized if iostream is not included in the program?

;

Which special of the following special characters does NOT need to be paired with another special character in C++?

std

The names defined in iostream are associated with which namespace?

//

A comment starts with what characters?

#

A preprocessor directive starts with what character or characters?

reserved word

An identifier that cannot be used as a variable name is a

long grossNationalProduct;

Declare a long integer variable named grossNationalProduct.

int populationChange;

Declare a variable populationChange, suitable for holding numbers like -593142 and 8930522.

int degreesCelsius;

Declare an integer variable named degreesCelsius.

unsigned degreesKelvin;

Declare an unsigned integer variable named degreesKelvin.

int profitStartOfQuarter; int cashFlowEndOfYear;

Declare two integer variables named profitStartOfQuarter and cashFlowEndOfYear.

main

Every C++ program must contain a __________ function.

0

How many spaces printed out by this statement: cout << "how" << "now" << "brown" << "cow" << "?";

hasFever

Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not?

mightBePrime

Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not?

// A SCRAMBLED program #include <iostream> using namespace std; int main() { cout << "Q"; return 0; }

Rearrange the following code so that it forms a correct program that prints out the letter Q:

cout << "Turing,Alan";

Suppose your name was Alan Turing. Write a statement that would print your last name , followed by a comma, followed by your first name . Do not print anything else (that includes blanks).

#include <iostream> using namespace std; int main(){ cout << "Gershwin,George"; return 0; }

Suppose your name was George Gershwin. Write a complete program that would print your last name , followed by a comma, followed by your first name . Do not print anything else (that includes blanks).

\t

The character escape sequence to force the cursor to advance forward to the next tab setting is:

\\

The character escape sequence to represent a backslash is:

\"

The character escape sequence to represent a double quote is:

\'

The character escape sequence to represent a single quote is:

a file containing code that is copied into the program at that point.

The word in the brackets of an include directive specifies


संबंधित स्टडी सेट्स

Developmental psych ch 5: Perception and motor development

View Set

Unit 1: Introduction to Hunter Ed

View Set

Fundamental Questions (250 question practice)

View Set

Unit 04 - Stockholders' Equity - Ch 15

View Set