电脑桌面
添加小米粒文库到电脑桌面
安装后可以在桌面快捷访问

完整版Thinking_in_C++_annotated_solution_guidecharpter_2VIP专享VIP免费

完整版Thinking_in_C++_annotated_solution_guidecharpter_2_第1页
完整版Thinking_in_C++_annotated_solution_guidecharpter_2_第2页
完整版Thinking_in_C++_annotated_solution_guidecharpter_2_第3页
Chapter 22-1Modify Hello.cpp so that it prints out your name and age (or shoe size, or your dog’ s age, if that makes you feel better). Compile and run the program. Solution:The original Hello.cpp appeared in the text as follows: // Saying Hello with C++#include // Stream declarationsusing namespace std; int main() { cout << "Hello, World! I am "<< 8 << " Today!" << endl; }Here ’ s my rewrite://: S02:Hello2.cpp#include using namespace std; int main() { cout << "Hello, World! I am Chuck Allison." << endl; cout << "I have two dogs:" << endl; cout << "Sheba, who is " << 5 << ", and" << endl; cout << "Muffy, who is 8." << endl; cout << "(I feel much better!)" << endl; } /* Output: Hello, World! I am Chuck Allison. I have two dogs: Sheba, who is 5, and Muffy, who is 8. (I feel much better!) */ ///:~I chose to have separate statements that send output to cout, but I could have printed everything in a single statement if I had wanted, like the example in the text does. Note that in the case of Sheba’ s age, I printed 5 as an integer, but for Muffy I included the numeral in the literal text. In this case it makes no difference, but when you print floating-point numbers that have decimals, you get 6 decimals by default. Bruce discusses later in the text how to control output of floating-point numbers. 2-2Starting with Stream2.cppand Numconv.cpp, create a program that asks for the radius of a circle and prints the area of that circle. You can just use the ‘* ’ operator to square the radius. Solution:The two programs mentioned above show how to do numeric input and output. The following solution to this exercise likewise uses the left-shift and rig...

1、当您付费下载文档后,您只拥有了使用权限,并不意味着购买了版权,文档只能用于自身使用,不得用于其他商业用途(如 [转卖]进行直接盈利或[编辑后售卖]进行间接盈利)。
2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。
3、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。

碎片内容

确认删除?
VIP
微信客服
  • 扫码咨询
会员Q群
  • 会员专属群点击这里加入QQ群
客服邮箱
回到顶部