C++ Basic Concepts

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

C++ is a

General purpose programming language

<iostream>

header defines the standard stream objects that input and output data

what is a set of logically connected statements

A block is a set of logically connected statements, surrounded by opening and closing curly braces.

how to write multiple statements on a single line

You can have multiple statements on a single line, as long as you remember to end each statement with a semicolon. Failing to do so will result in an error.

# the number sign

at the beginning of a line targets the compiler's pre-processor. In this case #include tells the pre-processor to include the <iostream> header

comments

comments are statements that explain what the code is doing. A comment beginning with two slashes (//) is called a single-line comment

Multi-Line comments

comments that require multiple lines begins with /* and end with */

what is the insertion operator

cout is used in combination with the insertion operator. Write the insertion operator as << to insert the data that comes after it into the stream that comes before.

what indicates the beginning and end of a function

curly brackets{} indicate the beginning and end of a function, which can also be called the function's body. The information inside the brackets indicates what the function does when executed.

A c++ program is a collection

of commands or statements

what is a way to print two lines

one way to print two lines is to use the endl manipulator, which will put in a line break

what does program execution begin with

program execution begins with the main function, int main()

what is used to perform input and output operations

streams are used to perform input and output operations

using namespace std;

tells the compiler to use the std(standard) namespace. The std namespace includes features of the c++ standard library

what does c++ compiler ignore

the c++ compiler ignores blank lines. In general. blank lines to serve to improve the code's readability and structure. Whitespace, such as spaces, tabs, and newlines, is also ignored, although it is used to enhance the program's visual attractiveness.

what is the entry point of every c++ program

the entry point of every c++ program is main(), irrespective of what the program does

what is used to terminate a statement

In C++, the semicolon is used to terminate a statement. Each statement must end with a semicolon. It indicates the end of one logical expression.

what is an alternative to endl

the new line character \n can be used as an alternative to endl. The backlash (\) is called an escape character, and indicates a "special" character

what results in the display of "hello world" to the screen

the next line, cout << "Hello World" results in the display of "Hello World!" to the screen

cin

to enable the user to input a value, use cin in combination with the extraction operator (>>). The variable containing the extracted data follows the operator.

new lines

two newlines characters placed together result in a blank line

return

The last instruction in the program is the return statement. The line return 0; terminates the main() function and causes it to return the value 0 to the calling process. A non-zero value (usually of 1) signals abnormal termination.


Ensembles d'études connexes

Session 1-Marketing Strategy, the Marketing Mix, STP, and the Triple Bottom Line

View Set

Pharmacology Chapter 52: Antidiabetics Nursing School Test Banks, PHARM Anti-inflammatories, PHARM Anti-tubercular Drugs, PHARM Chapter 26A - Penicillins and Cephalosporins, PHARM Dermatological Disorders, Pharmacology Chapter 30: Macrolides, Tetracy...

View Set

Total Rewards - Employee Benefits (SHRM AOL Study Guide)

View Set

Introduction to Sociology: Chapter 1 Quiz

View Set

Pediatric Success Gastrointestinal Disorders

View Set

7th Grade - Greek/Latin Prefixes, Suffixes and Roots

View Set

302 Hinkle Chapter 23: Management of Patients with Chest and Lower Respiratory Tract Disorders PrepU

View Set

NUR 1020 Fundamentals Chapter 4: Health of the Individual, Family, and Community

View Set

Assessment and Management of Patients with Biliary Disorders

View Set