Chapter 1. Getting Started(2)
来源:互联网 发布:烈火战神 完整源码 编辑:程序博客网 时间:2024/05/14 22:30
1.3. A Word About Comments
It is usually best to place a comment block above the code it explains.
Comment Pairs Do Not Nest(嵌套)
When commenting out a large section of a program, it can seem easiest to put a comment pair around a region that you want to omit temporarily. The trouble is that if that code already has a comment pair, then the newly inserted comment will terminate prematurely. A better way to temporarily ignore a section of code is to use your editor to insert single-line comment at the beginning of each line of code you want to ignore. That way, you need not worry about whether the code you are commenting out already contains a comment pair.
1.4.2. The for Statement #include <iostream> 1、Create val and initialize it to 1. 2、Test whether val is less than or equal to 10. 3、If val is less than or equal to 10, execute the for body, which adds val to sum. If val is not less than or equal to 10, then break out of the loop and continue execution with the first statement following the for body. 4、Increment val. 5、Repeat the test in step 2, continuing with the remaining steps as long as the condition is true. When we exit the for loop, the variable val is no longer accessible. It is not possible to use val after this loop terminates. However, not all compilers enforce this requirement.1.4. Control Structures
1.4.1. The while Statement
int main()
{
int sum = 0;
// sum values from 1 up to 10 inclusive
for (int val = 1; val <= 10; ++val)
sum += val; // equivalent to sum = sum + val
std::cout << "Sum of 1 to 10 inclusive is "
<< sum << std::endl;
return 0;
}
the overall execution flow of this for is:
The most common kinds of errors a compiler will detect:
Syntax errors.(语法错误)
Type errors.
Declaration errors.
- Chapter 1. Getting Started(2)
- Chapter 1. Getting started
- Chapter 1. Getting Started
- Chapter 2 Getting Started
- Chapter 1. Getting Started(1)
- Chapter 1. Getting Started(RETS helloworld)
- Chapter 1(2):Getting Started
- Chapter one: Getting started
- Chapter 0: Getting started
- Chapter 1:Getting Started
- !!!Chapter 1 Getting Started
- Chapter 1. Getting Started with the Sample Application
- 《C++ primer中文版》Chapter 1. Getting Started 第一章 快速入门
- Introduction to Algorithm - Summary of Chapter 2(0) - Getting started
- CMake Tutorial – Chapter 1: Getting Started
- Chapter 3: Getting Started With Devops
- Ruby-1.Getting Started
- 1.Getting Started
- VS2008技巧收集
- 一些基本设计模式
- JAVA中得到类相关路径 或 Servlet/JSP相关路径的方法
- PKU 2528 Mayor's posters离散的线段树
- Google wiki 语法
- Chapter 1. Getting Started(2)
- 使用XML的五种场合
- ZJU2965
- python字符串操作的一些例子
- 高人精讲 Makefile(企业级的)
- 进程和Windows程序的基本概述
- 一道求循环小数的程序员笔试题
- tomcat部署项目的三种方法
- 连接中国移动彩信网关发送彩信