cout << "H" << "el" << 'l' << 'o' << endl;
cout << "0.500 = " << 0.500 << endl;
cout << "Line 1$\backslash n$Line 2$\backslash n$"; cout << "Line 1$\backslash n$"; cout << "Line 2$\backslash n$";
cout << "Line 1$\backslash n$"; cout << "Line 1" << endl cout << "Line 2$\backslash n$"; << "Line 2" << endl;
cout << "\a" << "Hi" << endl << "there" << endl;(Does not work on the PCs, but works on Unix.)
#include <iostream.h> #include <iostream.h> main ( ) { main ( ) { int a; int a; ... int b; int b; ... ... ... a=1; a=1; b=3; b=3; cout << a+b << endl; cout << a+b << endl; ... ... } }(The dots stand for lots of other statements that are not important.)
#include <iostream.h> main ( ) { int pi; ... pi = 3.141593; ... return 0; }
#include <iostream.h> #include <iostream.h> main ( ) { main ( ) { float pi = 3.141593; float pi; .... .... .... pi=3.141593 .... .... area = pi*r*r area = pi*r*r .... ....
#include <iostream.h> #include <iostream.h> main ( ) { main ( ) { // Declarations: // Declarations: // Define pi: float pi = 3.141593; // pi is defined float pi = 3.141593; .... .... ....(The dots stand for lots of other statements that are not important.) The size of the program (number of lines or number of characters) is not an important consideration.
cout << "3*3 = " << 3*3 << endl;
float a; ...; a=1.5; cout << a << endl;
int a; ...; a=1.5; cout << a << endl;
cout << ".33 = " << 1/3 << endl;
cout << ".33 = " << 1./3 << endl;
cout << "Large: " << 300000*300000 << endl;
cout << "9 = " << 1+2*3 << endl;
cout << ".25 = " << 1./2.*2. << endl;
cout << "1 = " << 1./2./2. << endl;
int i; ...; i=1; cout << i++; cout << i << endl;
int i; ...; i=1; cout << ++i; cout << i << endl;
int i,j; ...; cin >> i >> j;