Advertisement

Tutorials for total noobs here

Started by January 24, 2003 09:17 PM
16 comments, last by Betrayer_of_Code 21 years, 9 months ago
Not bad for a start. Why not cstdlib instead of stdlib.h? Well ok, that's nothing.

For a complete noob, he/she has no idea how the grammar is, nor program runs. eg. "What does main(), #include means?".

While observing how my brother learn (well, I kinda force him to), this is the code he wrote (after first few chapter of the infamous "21days"):

    #include <iostream>using namespace std;  // i modified it a little here ;) void main(void) { int x = 5;  int y = 7;  int useranswer;  cout << "Pls enter number:";  cin >> useranswer;  if (useranswer == 12) {    cout << "correct." << endl  else     cout << "wrong." << endl;    cout << "The answer is useranswer" << endl  }  return 0;  // after some trial and error             // he change to:   return;}    

Notice anything wrong?? Why he did it this way?

[edited by - DerekSaw on January 26, 2003 10:49:33 PM]
"after many years of singularity, i'm still searching on the event horizon"
Derek:
*A number of missing semicolons
*To be pedantic, only put things in the global namespace you need, (i.e. "using std::cin;" instead of "using namespace std;")
*"<< "The answer is useranswer"" will literally output "The answer is useranswer", which is not the desired behavior
*main returns int. immutably. always. forever. yes, always. "return 0;" is correct, "void main" should be "int main"

Later,
ZE.

P.S. A randomizer might make things a little more entertaining

//email me.//zealouselixir software.//msdn.//n00biez.//
miscellaneous links

[twitter]warrenm[/twitter]

Advertisement
Now, don''t take offense... But those tutorials aren''t very good.

There is no detail, just a few comments, and they do little more than say "This is the product of writing this line of code".
"I thought Genius lived in bottles..." - Patrick Star
My sample is for reflection of what a complete newbie on programming looks like... even finished study the 1st five chapters of the books.

Hope your new rivision of tutorials REALLY get rid of newbie problems.

ZealousElixir, this is what you missed:
- though it is syntax correct, writing "if (useranswer == 12)" isn''t that good either.
- the ''funny'' braces for the if/else
"after many years of singularity, i'm still searching on the event horizon"
Heh, that was after about 30 seconds browsing over the code. I never said my list was exhaustive, but thanks for rounding it out.

[twitter]warrenm[/twitter]

no offence of anything but if you want my opinion on your tutorials im afraid to say it but they suck.


your tutorials are all explained in the code and I don''t feel that it should be done that way. There should be some explanation about c++ and all that stuff and then you give the hello world code (without all those fricking comments) and then more in detail explination after the code. The code should still have commenting of course but you are way overdoing it. My ideal amount of commenting for a hello world program is this:

// ''01 Main.pp''

// Input output stream header file
#include <iostream>

// Namespace declaration
using namespace std;

// Start of main function
int main
{
cout << "Hello World!\n" //Prints Hello World! on the screen
}

//End of program


really I think thats all the commenting a hello world program really needs. All the explanations should be done outside the source code in my opinion otherwise your going to eventually end up with very long source codes that don''t even look like source code because they have so much commenting.

-----------------------------
Programming is confussing!
AIM: Trebor DoD
-----------------------------AIM: Trebor DoDHompage: Thinking Digitally: My Web Blog
Advertisement
Ok,
first of all AHHHHHHHHHH
ok now that THATS over, I am re-writing the tutorials, and I am getting totaly different comments from every side. The reaso I wrote them like this is because this is the way I learnt it. So I figured that that was how tutorials were written. And they worked for my friend, who had never programmed anything before, and now hes goin along fine.
I dont know if you have seen the revised ones or the old one''s but I agree the old ones do suck. Some of your comments I do not understand, such as tell about stuff before the "Hello, World!" program, whats there to tell? Any whoo thaks for the comments
Im gonna go hang my tut-writing career.
BoC

Homepage
Luck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.
For any total noob out there Here is a like to my tutorials, thry them out
BoC HomepageLuck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.

int CPLAYER::attack() //to declare this you must first put wheither
{ //it is int,char etc... Like when you are defining any function
cout << "Attack";
}


Either return something or make it void...

This topic is closed to new replies.

Advertisement