r/learnprogramming • • 28d ago

confused with pointers in c++

I dont see the need for pointers when we could just write down the normal variable name, im genuinely so confused.

34 Upvotes

74 comments sorted by

View all comments

Show parent comment

3

u/Content_Mud_6469 27d ago

A few examples are possible. I am not strictly an educator, but I have mentored beginners and intermediates in code before. For something like this, pseudocode can be an effective tool.

  1. You can explain an if-statement in the context of a for / while loop.

    int x = 5 while(x < 10) { if(x == 10) { print("this is final loop") } x++ }

  2. If-statement in the context of runtime behavior

    print("Is the sky blue?") take in user input if(user input == yes) { print("correct!") } else { print("wrong!") }

2

u/nog642 26d ago

Yeah I think introducing user input early is very good.

Lets them write programs they can interact with too