欢迎大家来到IT世界,在知识的湖畔探索吧!
1:语句结束符
2:语句块,其内部定义的变量,函数,在其他语句块中不可见
3:需要给函数,变量起一个有意义的名字,便于理解及后续维护
4:函数的参数,及函数调用
5:常用错误信息的解读
// HelloWorld.cpp : 定义控制台应用程序的入口点。//时间://作者: 薛炜驰的第一个程序/*这个里面不进行编译*/#include "stdafx.h"#include <iostream>using namespace std;/*数据类型 变量名 = 初始值;int age = 0;函数的定义返回类型 函数名(函数的参数){ return 返回类型}*/int ddddd()//这样的名字不可取{ //int 123_ddd; int aa; //声明变量aa aa = 12;//给变量aa 赋值12; //int aa = 12; return aa;}int add(int x, int y) //函数{ int sum = 0; sum = x + y; return sum;}void test_sum(){ int sum1 = add(1, 2.999999999999999923); int sum2 = add(1, 2.222222222222222222); cout << "sum1: " << sum1 << ",sum2: " << sum2 << endl;}int main(int num,char *name){ int age = 0; while (1) //循环 { cout << "Please input your age" << endl; //换行 cin >> age; if (age > 9) { cout << "you are too old,please input again" << endl; } else { cout << "I am " << age << " year's old" << endl; break; } } //std::cout << "this is my first C++ code" << std::endl; test_sum(); return age;}
欢迎大家来到IT世界,在知识的湖畔探索吧!
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/38029.html