Q & A to Checkpoints Ch 2

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

a character literal

'B' is a character literal, not "B"

Assuming the char data type uses 1 byte of memory, how many bytes do the following literals use? 'Q' "Q" "Sales" '\n'

'Q' uses one byte "Q" uses two bytes "Sales" uses six bytes '\n' uses one byte

This will Compile properly...

// A crazy mixed up program #include <iostream> using namespace std; int main() { cout << "In 1492 Columbus sailed the ocean blue."; return 0; }

This Compile's properly...

// It's a mad, mad program #include <iostream> using namespace std; int main() { cout << "Success\n"; cout << "Success"; cout << " Success\n\n"; cout << "Sucess\n"; return 0; }

How would the following number in scientific notation be represented in E notation? 6.31 x 10 ^17

6.31E17

x 99bottles july97 theSalesFigureForFiscalYear98 r&d grade_report ?Which are the illegal variable names, and why?

99bottles : Variable names cannot begin with a number. r&d : Variable names may only use alphabetic letters, digits, or underscores

int main ( )

Beginning of a function. name this function is name, and the set of parentheses indicate that if is a function. Starting point of program.

What are the ASCII codes for the following characters? C F W

C = 67 F = 70 W = 87

using namespce std;

C++ organizes the names of programs entities. it declares that the program will be accessing entities whose name are part of the namespace called std.

C++ is a case-sensitive language

Ex: the name of the function main must be written in all lowercase letters,

Is this a integer division or floating-point division? what value will be stored in portion? portion = 70 / 3;

Integer division. The value 23 will be stored in portion .

Is the following assignment statement valid or invalid? if it is invalid, why? 72 = amount;

Invalid. The value on the left of the = operator must be an lvalue.

{ }

Left brace and Right Brace, associated with the beginning and ending of the main function main in between the braces.

// this is just a example.

Marks the beginning of a comment. The compiler ignores everything from the double slash to the end of the line. Comments help explain what's going on.

Yes or No: Is there an unsigned floating point data type? if so, what is it?

No

theSalesFigureForFiscalYear98 ? is the variable name Sales the same as sales? Why or why not?

Not the same, Variable names are case sensitive.

#

Preprocessor directive, it reads your program before it is compiled and only executes those lines beginning w/ # symbol.

What is wrong with the following program statement? char letter = "Z";

The string constant "Z" is being stored in the character variable letter .

What header file must you include in order to use string objects?

The string header file

Which data types uses more memory, an integer or an unsigned integer?

They both use the same amount of memory

Which of the following literals uses more memory? 20 or 20L

They both use the same amount of memory.

return 0;

This sends the integer value 0 back to the operating system upon the program's completion. the value 0 usually indicates that a program executed successfully.

int little; int big; little =2; big = 2000; cout << "The little number is " << little << endl; cout << "The big number is " << big << endl; return 0; ?list the variable and literals that appear?

Variables: little and big. Constants: 2, 2000, "The little number is ", "The big number is "

A function

a group of one or more programming statements that collectively has a name.

#include

causes the preprocessor to include the contents of another file in the program.

Write statements using the const qualifier to create named constants. Literal Value: Description: 2.71828 Euler's # (known in math as e) 5.256E5 # of minutes in a year 32.2 Gravitational acceleration constant (in feet per second^2) 1609 # of meters in a mile

const float E = 2.71828; const int MINUTES_IN_A_YEAR = 5.256E5; const float G_FEET = 32.2; const float G_METERS = 9.8; const int METERS_IN_A_MILE = 1609

Cout << "Programming is great fun! ";

displays message on the screen, the group of characters inside the quotation marks is called a string literal or string constant.

Variable functions and Objects

examples of program entities that must have names.

If a variable needs to hold numbers in the range -40,000 to +40,000, what data type would be best?

int

How would you consolidate the following definitions into one statement? int x = 7; int y = 16; int z = 28;

int x = 7, y = 16, z = 28;

; (semicolon)

marks the end of a complete statement in C++

If a variable needs to hold numbers in the range 32 to 6,000, what data type would be best?

short , or unsigned short .

int

stands for integer, it indicates that the function sends an integer value back to the operating system when it is finished executing.

<iostream>

the name of a file that is to be included. it contains code that allows C++ program to display output and read input. (header file)


Ensembles d'études connexes

Chapter 7 business law "Negligence"

View Set

NCLEX Cardiovascular, Hematologic, and Lymphatic Systems

View Set

Marketing Test 1 Review Questions

View Set

Nursing Informatics - Chapter 15

View Set