OK I can't stop the tradition so are first program in C++ will be of course "Hello World".
OK let's get started.
Hope that was easy enough.Code:#include<iostream> // This includes the files for input and output. int main() //Inside this is where the computer executes the code. { std::cout << "Hello World" << std::endl; //This prints Hello World, cout pronounced C out sends Hello World to the console window. //endl which stands for endline puts us on the beginning of the next line if you want to stay on the same line then just don't add std::endl just the ";" after your text. // std stands for standard which just tells the computer that this is a standard operation. system("PAUSE");//This makes the window stay up without this the window would open and shut in a flash.(This is not a good way to do that I'll show you how to fix it next.) return 0;//This ends the program. }
Now I'm going to show you how to save some time righting a story or paragraph and a better way to keep the window open.
At first I didn't want to use the namespace std thing because I thought it was bad programming but it will save you a lot of work if you have a lot of sentences to type.Code:#include<iostream> // This includes the files for input and output. using namespace std; //This now includes the standard files(I think:{)so in are Hello World line we don't have to type std:: before cout and endl. int main() //Inside this is where the computer executes the code. { cout << "Hello World" << endl; //This prints Hello World, cout pronounced C out sends Hello World to the console window. //endl which stands for endline and puts us on the beginning of the next line if you want to stay on the same line then just don't add endl just the ";" after your text. cin.get();//This is a better way to make the window stay up(Note this only works if you include namespace std; return 0;//This ends the program. }
Well I hope this tutorial helped you.
(if you have any problems PM me or leave a visitor message sorry but I don't know how to make the code windows bigger)


LinkBack URL
About LinkBacks






Reply With Quote




Bookmarks
Algorithms and Data Structures
Java tutorials
Algorithms Forum