• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

C++ Newbie

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys Alex here,

So I’m a HTML web developer that decided to try programming... and to be quite honest I’m terrible. I’m learning C++ right now, and I’m trying to write a program where you input into console your name and age, and when you do the program then states “Hello name, in five years you will be x age” so the program displays your name, and what your age will be five years after the input age.

I just don’t get the some of the syntax for the language, and being a visual learner if possible could someone explain to me how to set this up, and how?
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The secret to being a good developer is to realize that coding is 90% thinking, and only 10% typing.

Never start off a project trying to figure out the syntax.  Start by writing out in English (or your natural language of choice) what you want to do, step by step.  Then revise those steps into smaller steps.  Keep revising it until your steps are clear enough that a 10 year old child (or a 5 year old) can understand them, follow them, and have no questions about what to do next.  

If you have access to such a child, give it to them and see how many errors and omissions you have, then repeat.

Eventually, you will have a pretty well defined list of steps.

Then start coding, but only in the smallest amount possible before you compile, test, debug, repeat until it's perfect. If I were doing this project, on my first pass, i would have the code print nothing more than a simple "hello".  

Once that worked, change it to print "Please enter your name: " (or something like that).  At this point, i'm not trying to GET the name, i'm merely asking the question.  Once THAT works, I add the next piece.  I may think "ok, i know how to ask for a name, so asking for age shouldn't be that much harder, so i'll work on getting the name".  Once i can get it and save it, then hopefully doing the same two steps for age will be easier.

Try that.  see how far you can get.  When you have something and get stuck, post your code here and someone will help you further.
 
reply
    Bookmark Topic Watch Topic
  • New Topic