About the Program
The program takes a number the user entered and outputs that number doubled. I created two functions, one that gathers the number (getnumber), and another that doubles it (doublenumber). The program does work properly; however, the output is not completely accurate.
The Problem
The output is only right partially. I.e the user enters 50, the value is doubled and the output should be 100. Instead, the value outputs as 100114. Only the first few numbers seem to be what I want.
Source Code:
#include <iostream>
void doublenumber(int&);
void getnumber(int&);
int main() {
int value;
getnumber(value);
doublenumber(value);
std::cin.get();
std::cin.get();
return 0;
}
void doublenumber(int &refvar) {
refvar*= 2;
std::cout << "\nThe value you entered doubled is: " << refvar << '.\n';
}
void getnumber(int &userNum) {
std::cout << "\nEnter a number to double: ";
std::cin >> userNum;
}