网站大量收购独家精品文档,联系QQ:2885784924

c++上机实验报告.doc

  1. 1、本文档共104页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
c上机实验报告

实验1 熟悉上机环境及C++基础实验 1.实验目的和要求 (1)熟悉上机环境,了解Visual C++6.0集成开发环境、掌握源程序编辑、程序调试、查看变量、程序运行; (2)熟悉C++的程序结构,掌握main函数、保留字、变量及变量定义、输入与输出流等概念; (3)熟悉类与类对象的定义、类成员的调用。 2.实验内容 任务1:程序调试 #includeiostream.h int main() { cout您好!浙江大学欢迎您,愿您喜欢C++的输入输出。; cout2008; cout\n; cout20.1; coutendl; coutI amyears old student.; char name[30]; int age; coutplease give your name:; cinname; coutplease tell me how are you?; cinage; coutYour name isnameendl; coutyou areageyears old.; return 0; } 思考1:1)在程序中任何一行少一个“;”符号,有什么提示? error C2146: syntax error : missing ; before identifier cout 2)删除int age;这一行,编译后有什么错误提示。 error C2065: age : undeclared identifier 思考2:1)C++中的注解有哪些? C++注解形式有两种:单行注解(//)以及多行注解(/*….*/) 2)应用输入输出流应包含什么库? 输入输出流库 iostream.h 3)定义变量有什么含义? 给变量分配存储空间 4)常用变量有哪些基本类型? int char double float 任务2:程序调试 在实验1的源程序基础上,作以下程序的调试,并回答相关问题。 (1)用单行注释符”//”注解预处理命令,编译程序有什么提示? error C2065: cout : undeclared identifier error C2297: : illegal, right operand has type char [46] warning C4552: : operator has no effect; expected operator with side-effect error C2297: : illegal, right operand has type char [2] error C2296: : illegal, left operand has type const double error C2297: : illegal, right operand has type const double error C2065: endl : undeclared identifier warning C4552: : operator has no effect; expected operator with side-effect error C2297: : illegal, right operand has type char [5] error C2297: : illegal, right operand has type char [23] error C2065: cin : undeclared identifier error C2297: : illegal, right operand has type char [30] error C2297: : illegal, right operand has type char [28] warning C4552: : operator has no effect; expected operator with side-effect error C2297: : illegal, right operand has type char [13] error C2297: : illegal, right operand has type char [8] 如果程序中使用函数fabs,应该增加什么样的预处理? 增加一句 #includemath.h (2)把int main()写成int Main( ) ,编译程序有什么提示?请回答在C++程序设计对大小写有什么要求? error C4716: Main : must return a value

文档评论(0)

yaobanwd + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档