i know about java and c++ has the same concepts ,all the code run when the code go to main ,main control of the beginning of code and we do function and classes to avoid loading in memory
I do have experience with C++. The code is nicely managing the flow of the program by calling on functions defined elsewhere in the program. The program initially sets up some counting variables to be used In a while loop to keep increasing the difficulty until a maximum number of successful plays has been achieved.
I’m guessing, but I think since the main () function is the point of execution where the program starts, Ben’s code here is showing that the program is always going to start at the lowest difficulty, or what will always be the main entry point for this particular game
So what I think that main() does is that it runs the piece of code you put between { } when you let the script run. It doesn’t repeat itself unless you purposely put it in.
For me it is main program in code. Inside we place subprograms.
I believe the main function executes a certain set of code entered within the brackets
I thin the main() is a function where statements would be put in for example { cout << “hello”;
and also you need to make sure you get no errors by having return 0; and if everything is good it
return will send the value of 0.
The main function is what allows your code to be able to run in the compiler without your code will not be able to run.
In terms of the code it runs the PlayGameAtDifficulty beginning at level 2 and runs up until it reached the highest difficulty(which is 10) and if the player reached the highest difficulty and passes it then displays the message “WOW - You’re a master hacker!”
Maybe main() function shows that it’s the core function of the program?Like,when you look at it,you understand where all other functions should be stored and where the heart of the program is.Perhaps it shows the editor/computer to run this function as first one,no matter where it’s place(Ben placed it in the end)
I believe main() is the primary function for each piece of source code. It is what the source code “does”.
The main() in my opinion is a function, which has all the stuff your program. You can also make another functions in the same program (outside the function main()), but their result won’t be visible as long as you wouldn’t mention them in function main().
I am not sure what main() does, to be honest, but it seems like it would hold the main part of your code. Before it, you set all the variables and write all the programming shortcuts (for example, answer=1) and then use main() to write the actual program.
My guess is that main()
is the “main”-function of the program. Aside from declarations and includes, this is where the program starts to run. From main()
, other functions can be called and I think that the program stops running when the main()
is finished.
main() is the primary function and in this case, it sets an initial value for the difficulty and the maximum, has a while statement where it feeds the difficulty value to the function “PlayGameAtDifficuliy” where the game actually happens, clears some stuff on the screen, adds one to the difficulty keeps on going until the difficulty goes over the maximum. In which after the victory message is printed and the program exits.
The Main function executes all other functions, and if everything is as it should be (it gets to the end with the code) it will return 0.
Am I correct?
The Main function is the instigator functions that will run all other code thats written beneth it, i think
The main() function is what gets run by the compiler and output to the terminal. It’s like the center of activity for the program itself, and other methods can be passed in to it to modify the program
We can determine the borders of our program inside the main() function. Before the main function we should #include libraries. The main() function ends with a return value. For example, think about a flower, in our case the main() function is earth, the codes we write inside the main() function is our seed, and the return value is a flower. I hope I did not failed too hard
main () runs through the statements provided within it’s body, and currently starts by resetting, before proceeding to run the game, amping up the difficulty until eventually reaching a max difficulty, which after than returns a message stating you won if successful.
The command “main()” allows the computer to run a program. Its like a skeleton in the human body, its what supports everything else and makes a smooth running program. Or at least its what i think.