Quick question here, or at least hopefully so. I was just going through the tutorials ag, and writing myself simple programs for examples for the future. So I was just thinking a bit, and wrote up this program:
And the code works nicely. It basically multiplies whatever the person said, by 5. Simple. The question is, is this any faster, then actually doing x * 5? I recognize that using pointers will "grab" the said value faster, as all it has to do is point towards it, rather then actually grabbing it. Is the above true while using the variable in other things, such as multiplication?
using namespace std;
pointer = &x;
cout<<"Insert a whole number: ";
cin>> x; // Makes x = Number you said
cout<< "The number you chose is: ";
cout<< *pointer; // Uses the pointer function, which points towards "x"
cout<< "\nThis number multiplied by 5 is: ";
answer = (*pointer * 5); // Multiples x by 5, but using pointer
cout<< ""<< answer <<""; // Shows answer