[ C++ ] DAY-1 (std::cout and std:: endl)

Posted: December 31, 2010 in C++

#include <iostream>
int main()
{
 std::cout << “Hello there.\n”;
 std::cout << “Here is 5: “<< 5 << “\n”; //将3个值传递个(sending 3 value to)cout:1.Here is 5;2. 5;3.\n
 std::cout << “There mainpulator std:endl “;
 std::cout << “writes a new line to the screen.”;
 std::cout << std::endl; //换行符(change to a new line)
 std::cout << “Here is a very big number:\t” << 70000;
 std::cout << std::endl;
 std::cout << “Here is the sum of 8 and 5:\t”;
 std::cout << 8+5 << std::endl;
 std::cout << “Here’s a fraction:\t\t”;
 std::cout << (float) 5/8 << std::endl;
 std::cout << “And a very very big number:\t”;
 std::cout << (double) 7000*7000 << std::endl;
 std::cout << “Ethan is a C++ programmer!\n”;
 return 0;
}

#include <iostream>
int Namespace();
int main()
{
 using std::cout; //使用(using)Using Keyword
 using std::endl;

 cout << “Hello there!”;
 cout << endl;
 cout << “Ethan is a programmer!\n” << endl;

 Namespace();
 return 0;
}

int Namespace()
{
 using namespace std;  //使用 标准名称空间(using standard name space)(除非特殊说明,否则任何对象都来自标准名称空间(if noting, unless any object is from name space))
 cout << “Hello world!”;
 cout << endl;
 cout << “This is a C++ coding.\n”;
 return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s