#include "stdio.h"// we need to include some external files
#include <iostream>
using namespace std;
int main() // the main function (called when you execute your program)
{
cout << "Hello Neo...\n"; // print to screen
getchar(); // wait for a key to be pressed
return 0; // the main function returns zero
}
Alternative 2:
#include "stdio.h" // include our standard input/output header file
int main() // the main function (called when you execute your program)
{
printf("Hello! Please press a key to continue.\n"); // print to screen
getchar(); // wait for a key to be pressed
return 0; // the main function returns zero
}
/*
first you must include the necessary files to be able to use cout
#include
using namespace std;
stdio header file is necessary to use getchar()
#include
all c and c++ programs must have a main function the main function
is the first function that run when the program is executed
void main()
{
}
void means empty, main is the name of the function.
"{" starts the function "}" ends the function.
when coding in linux the main function needs to return a value
int means return an integer, in this case zero
int main()
{
return 0;
}
you will learn more about functions in the function tutorial.
*/
// end commands with ";" in c and c++
// comment your code by using slashes //my comment
// commment out a whole block by using: /* and */
/*
my comment line 1
my comment line 2
*/
// cout <<""; will print out the text for you
// to get a line break use endl or \n like this:
// cout << "Hello Neo..." << endl;
// cout << "Hello Neo...\n"
Download Visual C++ Source Code
I hope you found this c++ tutorial useful!
Don't forget to mention Apron Tutorials in your References!