This tutorial I aimed for those who would like to learn to do basic output in c and in c++. This is very easy and for begginers, fun.
Let's get down to business:
C Version:
Explanation:Code:#include <stdio.h> int main() { printf("Hello World"); system("PAUSE"); return 0; }
#include <stdio.h> - This piece of code basically means that you want to include the Standard Input and Output header file. Header files are to be included in pretty much all your code seeing as this is where the "actual" code is.
int main() { - This opens a function called main that returns and integer. All applications much have a main function.
printf("Hello World"); - This prints to the screen "Hello World"
system("PAUSE"); - Basically stops the application from closing seeing as it has already ran the code we wanted it to run. Another way of doing so is: getchar().
return 0; - This is returned stating the application ran with no problems.
} - Closes the main function.
C++ Version:
Explanation:Code:#include <iostream> int main() { cout << "Hello World"; system("PAUSE"); return 0; }
#include <iostream> - This piece of code basically means that you want to include the Input and Output Stream header file. C++ header files do not need the .h extention. Header files are to be included into almost, if not, all applications, seeing as they hold the "real code".
int main() { - This opens a function called main that returns and integer. All applications much have a main function.
cout << "Hello World"; - This prints to the screen "Hello World"
system("PAUSE"); - Basically stops the application from closing seeing as it has already ran the code we wanted it to run. Another way of doing so is: getchar().
return 0; - This is returned stating the application ran with no problems.
} - Closes the main function.
Very nicely done! +rep.
grmph ,
why you must do the same as me ?
and about system("PAUSE"); , case matters !
I know this. My bad, didn't mean to not case it.
+rep mate![]()
Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!
Thanks mate. Means a lot to me.
I am a beginner in learning C and ur explanation is so easy & so simple
thank u very much
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks