Intro to Comptuer Programming Preamble to Ch 2

¡Supera tus tareas y exámenes ahora con Quizwiz!

besides endl what is another code for hard return?

"\n"

A preprocessor directive starts with what character or characters?

#

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

#include <iostream> using namespace std;

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

#include <myFuncs.h> using namespace std;

What is the usual syntax for a compiler directive?

#include <program_name> and they do not end with semi colons

What is the symbol for multiplication?

*

A comment starts with what characters?

//

Rearrange the following code so that it forms a correct program that prints out the letter Q: int main() } // A SCRAMBLED program return 0; #include <iostream> cout << "Q"; { using namespace std;

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

Write a literal representing the integer value zero.

0

What are the 2 different codes to let the compiler know that this is a comment?

1. // Everything on the same line after the // is ignored by the complier and treated as a comment 2. /* Comments can span several lines by beginning them with a /* and ending them with a /*

What are the 3 types of C++ data types?

1. language defined 2. system defined 3. user defined

Which of the following is NOT a legal identifier? a. outrageouslyAndShockinglyLongRunon b. _42 c. _ d. lovePotionNumber9 e. 7thheaven

7thheaven

Which special of the following special characters does NOT need to be paired with another special character in C++? a. ( b. ; c.{ d. "

;

When does iostream need to be included?

Anytime there is a display to the monitor (using cout) and/or data to be inputed form the keyboard (using cin)

What are the required comments for this class?

Begin each program with your name, course section number, programming assignment number, date written, and teh purpose of the program on separate lines

Used to document program listing (let a reader of the program know what the program is supposed to accomplish)

Comments

The compiler finds programs located in a file folder called STL (Standard Template Library) and combines them with your source prior to compiling

Compiler Directives or preprocessor directive

an input device that an operator can use to monitor and control the computer system

Console Output

What are the two types of statements that the function body can have?

Declalartion and executable

Indicate to the compiler what data is needed by each function in the program. The compiler assigns a memory location for all names used.

Declaration statement

A collection of related statements in C++ all under one name (enclosed in braces {....})

Function

The _______ is enclosed within the braces {...} of the main function.

Function body

The use of ____ files in C++ saves the programmer from having to write the extra code (usually hundreds or even thousands of lines of code) that is common to many C++ programs

Header

Used by programmers to name variables constants and functions

Identifiers

What is an abbreviation for input/output stream

Iostream

What is the entry point of the program (where the program begins execution)?

Main function

int main ( ) and int main (void) mean the same thing. What do they mean?

No values are being passed into the function

In C++ programming is number_in the same as Number_in or number_IN?

No; C++ is case sensitive and the C++ compiler will differentiate between the cases of characters; most C++ programs are written in lowercase with the exceptions of comments and messages displayed to the user of the program

Functions can receive values and return values. These values are also known as?

Parameters or arguments

used to display messages and/or data to the user

Program output

Identifiers that have a special meaning to C++ and therefore cannot be used as an identifier

Reserved words

...

Stream Output

In order to send text to the console window follow cout with the ____ and the text you want to display in quotation marks with a semicolon at the end of the statement.

Stream insertion operator <<

____ defined data types are usually defined in header files (like cin and cout).

System

What does int in the function header line int main ( ) indicate?

The function will pass an integer value back to the operating system

How are identifiers written?

They can consist of numbers, letters, and underscores but don't start with an underscore; they should begin with a letter; the initial letter may then be followed by letters, digits, and understores; there is no maximum length but first 32 identifiers must be distinctive for different identifiers; good to use meaningful identifiers ex. for student number could name it student_number not sn

What must be declared before they are used in an executable statement?

Variables (values that can change) and constants

Are comments ignored by the compiler?

Yes

Which of the following IS a legal identifier? a. 5_And_10 b. Five_&_Ten c. ___________ d. LovePotion#9 e. "Hello World"

_______________

The text of a comment a. is checked by the compiler for accuracy b. must appear in the first line of the program c. is printed out when the program runs d. can be anything the programmer wants to write

can be anything the programmer wants to write

defined in the header file iostream

cin>>

Preprocessor directives are carried out just before a program is processed by the ____.

compiler

What object will not be recognized if iostream is not included in the program?

cout

_____ is used to refer to the console window in C++ window

cout (console output)

Define each part: cout<<"Enter an integer"<<endl;

cout<<defined in the header file iostream cout<< "Enter an integer" display to the monitor Enter an integer <<endl; endl causes the monitor to advance to the next line (same as hitting return)

how a particular value is represented in memory

data type

inserts a hard return (starts a new line)

endl (end line)

used for computations and to store the results in a variable name. Ex. number_twice=2*number_in;

executable statements

The word in the brackets of an include directive specifies a ____ containing code that is copied into the program at that point.

file

Of the following variable names, which is the best one for keeping track of whether a patient has a fever or not? a. temperature b. feverTest c. hasFever d. fever

hasFever

cin>>number_in;

indicates that the next data value entered by the user is extracted from the keyboard and placed in the identifier number_in

used to obtain data from the keyboard for the program to use

input

____ indicates the data type - what kind of data will be stored

int

Write a literal representing the integer value zero.

int count;

Declare an integer variable named degreesCelsius .

int degreesCelsius;

int should be used as the data type when the identifier is a(n)____.

integer; (integers can only be numeric digits that are positive or negative)

int is an example of what kind of data type?

language defined

Every C++ program must contain a ____ function.

main

Which of the following is NOT a C++ keyword? a. using b. int c. main d. namespace e. return

main

In C++ programs the ____ function is required and there can only be one function named ____.

main; main

Of the following variable names, which is the best one for keeping track of whether an integer might be prime or not? a. divisible b. isPrime c. mightBePrime d. number

mightBePrime

Which is the best identifier for a variable to represent the amount of money your boss pays you each month? a. notEnough b. wages c. paymentAmount d. monthlyPay e. money

monthlyPay

_________ , ________ are identifiers - the names to be used in the programs

number_in, number_twice

The ____ that can be performed on the value is determined by its data type.

operations

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

reserved word

What do you use at the end of the main function to return a 0 back to the operating system?

return 0;

The names defined in iostream are associated with which namespace?

std

endl is an example of a ______ .

stream manipulator

What does int number_in, number_twice; tell the compiler?

to allocate the memory locations that will be referenced by "number_in" and "number_twice"; these memory locations will contain an integer

What line should always be placed immediately after all #include?

using namespace std;


Conjuntos de estudio relacionados

Texas Life and Health other questions

View Set

Matter and Energy in Ecosystems Glossary

View Set

Chapter 3 Baking and Pastry Equipment

View Set

test 1 NSG 110 practice questions

View Set

Incorrect Check Understanding Week 6

View Set