//input and output
#include <iostream>
using namespace std;
int main ()
{
int carrots;
cout<<"How many carrots do you have?"<<endl;
cin>>carrots; //C++ input
carrots=carrots+2;
cout<<"Hear are two more."<<"Now you have"<<carrots
<<"carrots"<<endl;
return 0;
}
注:
1.与cout一样,cin也是一个智能对象。在此程序中,程序将carrots声明为一个整形变量,输入被转换为计算机用来储存整数的数字形式