I am working on a program that asks for 2 number between 1 and 100.
Its supposed to say how much even numbers are in between these two numbers.
Then I need it to list out all the even numbers between those numbers...
So far I got it to calculate the number of even numbers, but can't seem to figure out how to list them...
heres my code:
#include <iostream.h>
int main()
{
int firstnumber;
int secondnumber;
int FunctionEVEN;
int FunctionNumber;
int countnum;
int i;
int a;
float b;
int c;
int d;
int e = 0;
int f;
int g;
cout << "Please insert your first number choice between 1 and 100\n";
cin >> firstnumber;
cout << "Please insert your second number choice between 1 and 100\n";
cin >> secondnumber;
FunctionEVEN = firstnumber - secondnumber;
FunctionEVEN = FunctionEVEN/2;
if (FunctionEVEN < 0)
{
FunctionEVEN = FunctionEVEN * (-1);
}
else
{
FunctionEVEN = FunctionEVEN;
}
cout << "There are " <<FunctionEVEN <<" even numbers between both chosen numbers\n";
I did this in Microsoft Visual C++
Could anyone edit my code so it also lists even numbers??
I tryed doing While loop, but am still learning, and couldn't get it right :(
heres it with the loop :
b=c;
if (b > c)
{
d = 1;
}
else
{
d = 0;
}
i = firstnumber;
while (secondnumber < 1)
{
i++;
if (d == i)
countnum = firstnumber - 1;
}
countnum = countnum + 2;
cout << countnum << "andl\n";
d = 0;