C ++ programming exercise and answer note (Chapter 1) (Normal classic learning guidance series)

xiaoxiao2021-03-06  103

Chapter One

1.2 Program Example

I. Hello World Program:

Form 1:

#include

int main ()

{std :: cout << "Hello, World! / N;

}

Form 2:

#include

Using namespace std; // Using namespace

int main ()

{

Cout << "Hello, World! / N;

}

Related knowledge: 1. Preprocessing instructions

2. Space

.1.3 Output operator

ENDL flag effect: Print the cursor to the next row and clear the buffer

1.4 characters and text

Character is stored in an integer in the computer

Space character indicates: ''

1.6 program tag

When the compiler is inspected, the omissible tag is discovered when checking the next tag.

1.8 objects, variables and constants

Object is a region connected in memory

The size of the object is determined by the compiler. EG, GNU C , INT size is 4, in Borland C , INT size is 2

Usually habits with uppercase letters to represent constant markers

Constants must be initialized when declaring

Review questions:

The role of the statement: tell the type and variable name represented by the compiler

The role of pretreatment of pseudo-instructions: including the contents of the header files

% Is "Search" operator

1.15 identify the character of the ASCII code to 100: Cont << "char (100)" << char (100) << endl;

1,18 integer overflows Different from floating point number: Integer "Roll" is negative, floating point numbers are set to infinite constants.

1.19 1.20 Distinguish between runtime errors and compile errors: EG. Overflow and except 0 .....

exercise

1.1 minus 1 different writing method from N: n = N-1; N - N- = 1;

1.5 Reduce the variable N to 1 after 1, add to Total: Total = Total - -N; => Total = - -N

1.13 causes short variables that overflow: short = 0; short- = 1000; Short - = 2000; .......

转载请注明原文地址:https://www.9cbs.com/read-104110.html

New Post(0)