请选择 进入手机版 | 继续访问电脑版
楼主: Nicolle
3658 8

[求书]C++ How to Program, Ninth Edition [推广有奖]

巨擘

0%

还不是VIP/贵宾

-

TA的文库  其他...

Python(Must-Read Books)

SAS Programming

Must-Read Books

威望
16
论坛币
12402323 个
通用积分
1620.7415
学术水平
3305 点
热心指数
3329 点
信用等级
3095 点
经验
477211 点
帖子
23879
精华
91
在线时间
9878 小时
注册时间
2005-4-23
最后登录
2022-3-6

Nicolle 学生认证  发表于 2015-5-24 07:27:14 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

本帖被以下文库推荐

zli08 发表于 2015-6-13 21:49:07 |显示全部楼层 |坛友微信交流群
Chapter 2 Self-Review Exercises

2.1 Fill in the blanks in each of the following.

a) Every C++ program begins execution at the function ________.

b) A(n) ________ begins the body of every function and a(n) ________ ends the body.

c) Most C++ statements end with a(n) ________.

d) The escape sequence \n represents the ________ character, which causes the cursor to position to the beginning of the next line on the screen.

e) The ________ statement is used to make decisions.

2.2 State whether each of the following is true or false. If false, explain why. Assume the statement using std::cout; is used.

a) Comments cause the computer to print the text after the // on the screen when the program is executed.

b) The escape sequence \n, when output with cout and the stream insertion operator, causes the cursor to position to the beginning of the next line on the screen.

c) All variables must be declared before they’re used.

d) All variables must be given a type when they’re declared.

e) C++ considers the variables number and NuMbEr to be identical.

f) Declarations can appear almost anywhere in the body of a C++ function.

g) The modulus operator (%) can be used only with integer operands.

h) The arithmetic operators *, /, %, + and – all have the same level of precedence.

i) A C++ program that prints three lines of output must contain three statements using cout and the stream insertion operator.

2.3 Write a single C++ statement to accomplish each of the following (assume that neither using declarations nor a using directive have been used):

a) Declare the variables c, thisIsAVariable, q76354 and number to be of type int (in one statement).

b) Prompt the user to enter an integer. End your prompting message with a colon (:) followed by a space and leave the cursor positioned after the space.

c) Read an integer from the user at the keyboard and store it in integer variable age.

d) If the variable number is not equal to 7, print "The variable number is not equal to 7".

e) Print the message "This is a C++ program" on one line.

f) Print the message "This is a C++ program" on two lines. End the first line with C++.

g) Print the message "This is a C++ program" with each word on a separate line.

h) Print the message "This is a C++ program". Separate each word from the next by a tab.

2.4 Write a statement (or comment) to accomplish each of the following (assume that using declarations have been used for cin, cout andendl):

a) State that a program calculates the product of three integers.

b) Declare the variables x, y, z and result to be of type int (in separate statements) and initalize each to 0.

c) Prompt the user to enter three integers.

d) Read three integers from the keyboard and store them in the variables x, y and z.

e) Compute the product of the three integers contained in variables x, y and z, and assign the result to the variable result.

f) Print "The product is " followed by the value of the variable result.

g) Return a value from main indicating that the program terminated successfully.

2.5 Using the statements you wrote in Exercise 2.4, write a complete program that calculates and displays the product of three integers. Add comments to the code where appropriate. [Note: You’ll need to write the necessary using declarations or directive.]

2.6 Identify and correct the errors in each of the following statements (assume that the statement using std::cout; is used):

a)

if ( c < 7 );
   cout << "c is less than 7\n";


b)

Click here to view code image

if ( c => 7 )
   cout << "c is equal to or greater than 7\n";


已有 1 人评分论坛币 收起 理由
Nicolle + 20 鼓励积极发帖讨论

总评分: 论坛币 + 20   查看全部评分

使用道具

Nicolle 学生认证  发表于 2015-6-13 23:45:54 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

Nicolle 学生认证  发表于 2015-6-13 23:46:59 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

Nicolle 学生认证  发表于 2015-6-13 23:48:37 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

Nicolle 学生认证  发表于 2015-6-13 23:51:02 |显示全部楼层 |坛友微信交流群
提示: 作者被禁止或删除 内容自动屏蔽

使用道具

auirzxp 学生认证  发表于 2015-6-14 00:06:48 |显示全部楼层 |坛友微信交流群

使用道具

auirzxp 学生认证  发表于 2015-6-14 00:08:25 |显示全部楼层 |坛友微信交流群

使用道具

WonderToe 发表于 2015-7-3 15:40:07 |显示全部楼层 |坛友微信交流群
已上传
https://bbs.pinggu.org/thread-3784732-1-1.html

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加JingGuanBbs
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-3-29 08:23