C++ Tutorial Video part 9

0 Sachin Murpana · January 28, 2015
Hi I am new to programming.
I wanted to know what's the use of creating a function.
As per video no 9 following is the code.
#include <iostream>
using namespace std;

int main() {
return 0;

void printsomething(){
        cout << "xxxx" << endl;

Don't you think we could had directly used 
int main() {
cout << xxxx" << endl

Post a Reply


Oldest  Newest  Rating
0 Troy Jones · January 29, 2015
It's easier to comment out 1 method to debug, rather than multiple lines in a single method.
+1 Jake Scaife · January 29, 2015
As a new programmer, Java is certainly more forgiving than C/C++. Python is also a great choice for beginners.

However if you feel you are up to it, if you can nail C++, a lot of other languages such as Java, C and Python will quickly fall into place when/if you decide to learn how to use them.

C++ is very similar to Java, however some aspects of C++ can be slightly daunting for beginners as you get lower into the programming. Don't let this put you off though, I know a lot of programmers who began with C++ and many are better off for it.
+1 Sachin Murpana · January 29, 2015
Thanks thanks a ton for your answer.
I am in the learning phase so please do expect some silly questions from me, thanks in advance again.

I also wish to know whether I should first start with C, C++ or Java as a new program learner
0 Yan Yan · January 28, 2015
Yes, we can just do the way like you said. 

But as number of lines goes up enough to be crazy, programmers just prefer to split to different some segments to code and test.
+2 Jake Scaife · January 28, 2015
Yes, you could certainly do this - for this particular scenario.

I believe the intention of the video was to highlight how to use functions, such as the syntax and purpose behind them.
  • 1



Used in many types of software including music players, video games, and many large scale applications.

Bucky Roberts Administrator