Saturday, November 29, 2008

C++



I am major in Computer Science and Information Engineering in Chang Gung University. At the medium of the semester, we start to write program! I have already anticipated for a long time. The first program we wrote is printing a sentence” Hello World! “on the screen. The program codes are below:



#include
using namespace std;

int main()
{
cout << "Hello World" <<>
return 0;
}

It is a simplest and most basic program. Our goal of semester as if is to write three hundred lines of program. It seems that we still have a long way to go. There are just five lines above!

After several weeks, we can write program similar following two programs.



#include
using namespace std;

int main()
{
int count;
cout << "Let us make the addition."
<< "Give me a number." <<>
cin >> count;
count += 2;
cout << "The resualt that the number add two is " <<>
return 0;
}





#include
using namespace std;

int main()
{
int X, Y;
cout << "Please Give me two numbers."<<>
cout << "The first number is " ;
cin >> X;
cout << "The second number is ";
cin >> Y;
if ( X > Y )
cout <<"The first number is larger than the second number." <<>
else if ( X == Y )
cout <<"The first number is equal to the second number." <<>
else
cout << "The first nember is smaller than the second nember."<<>
return 0;
}





The first above is a program that adding 2 to a number and the second program is comparing the size of number. It is difficult to image that we will write thousands or tens of thousands lines of programs. But if we can develop software randomly to do what we want to do, what is a joyful matter!

No comments: