I'm pretty new coding C++, but still practicing it.
I have the following code of main.cpp file:
#include "additionalFile.h"
#include <iostream>
int getValueFromUser() {
std::cout << "Enter an integer: ";
int input{};
std::cin >> input;
return input;
}
void printDouble(int value) {
std::cout << value << " doubled is: " << value * 2 << "\n";
}
int main() {
printDouble(getValueFromUser());
addNumber(inputFirstNumber(), inputSecondNumber());
return 0;
}
The following code of additionalFile.cpp file:
#include <iostream>
int inputFirstNumber() {
std::cout << "Enter first integer: \n";
int num;
std::cin >> num;
return num;
}
int inputSecondNumber() {
std::cout << "Enter second integer: \n";
int num;
std::cin >> num;
return num;
}
void addNumber(int x, int y) {
std::cout << "Your result is " << x + y << "\n";
}
And code for additionalFile.h file:
#pragma once
int inputFirstNumber(); int inputSecondNumber(); void addNumber(int x, int y);
The question is: Why, when i run the program and it runs addNumber() function, does it ask me for the second digit to input, and then for the first one? The order looks misordered.
Thank you in advance!
addNumber(inputFirstNumber(), inputSecondNumber());
In this line i've exchanged parameters vice versa, and it asked me to input digits in proper order. But i want to get the basic clue of the issue.