I just add and took some stuff away and it dosnt work
This should find numbers in range between the 2numbers that the user types
This works>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
int main()
{
int v1 = 0, v2 = 0;
std::cout << "Enter two integers to find numbers in their range (inclusive): " << std::endl;
std::cin >> v1 >> v2;
int current = std::min(v1, v2);
int max = std::max(v1, v2);
while (current <= max)
{
std::cout << current << std::endl;
++ current;
}
return 0;
}
This dosn`t work.The only thing I did is add usingnamespace std; and take away std:: What is the problem?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
int v1 = 0, v2 = 0;
cout << "Enter two integers to find numbers in their range (inclusive): " << endl;
cin >> v1 >> v2;
int current = min(v1, v2);
int max = max(v1, v2);
while (current <= max)
{
cout << current << endl;
++ current;
}
return 0;
}
max is a c++ function
i used max_ variable instead of max
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
usingnamespace std;
int main()
{
int v1 = 0, v2 = 0;
cout << "Enter two integers to find numbers in their range (inclusive): " << endl;
cin >> v1 >> v2;
int current = min(v1, v2);
int max_ = max(v1, v2);
while (current <= max_)
{
cout << current << endl;
++ current;
}
return 0;
}
EDIT ::
I recommend that you use code::blocks, because it marks operators and functions in green color, and variables in black, by that way, you can notice easily.
Thank you Peter87
I miss up when using c++ and trying to understand the program in English and in Arabic (my mother language).
post fixed, it's a function.
operators are >> << + - * / &
functions are max , min , and other functions,
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::min;
int main()
{
int v1 = 0, v2 = 0;
cout << "Enter two integers to find numbers in their range (inclusive): " << std::endl;
cin >> v1 >> v2;
int current = min(v1, v2);
int max = std::max(v1, v2);
while (current <= max)
{
cout << current << endl;
++ current;
}
return 0;
}
I think std::max is not as same as max when not using namespace;
std::max in this case is a function
and max is a variable
but when using std::max (Or using namespace std)
max is a function
while you are using max as a variable, which is invalid