我正在学习C++,我正在尝试制作一个打印5个变量的简单程序,正如我的书中所说,但它并没有执行我的代码.
#include<iostream>
using namespace std;
int main()
{
//Program Code below
return 0;
char letter; letter = 'A'; //Declared, then initialized
int number; number = 100; //Declared, then initialized
float decimal = 7.5; //Declared AND initialized
double pi = 3.14159; //Declared AND initialized
bool isTrue = false; //Declared AND initialized
cout<<"Char letter: "<<letter<<endl;
cout<<"Int number: "<<number<<endl;
cout<<"Float decimal: "<<decimal<<endl;
cout<<"Double pi: "<<pi<<endl;
cout<<"Bool isTrue: "<<isTrue<<endl;
}
Run Code Online (Sandbox Code Playgroud)
一旦您的代码执行此行
return 0;
Run Code Online (Sandbox Code Playgroud)
没有其他行的代码会被执行-从实用的角度来看,你的程序已经结束.将此行向下移动,使其成为main()函数执行的最后一行代码.
| 归档时间: |
|
| 查看次数: |
216 次 |
| 最近记录: |