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;

Its go some minor bugs in it... if you try it out, you'l see them, but other then that, it works good
What grade do you think I deserve for this program??

//				Prints out even numbers, and counts them


#include <iostream.h> //iostream.h is included to be able to use cout, and cin.

//all the functions used.
int functionEVEN();

int main()
{
//all my declared variables.
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;  //gets first number.

cout << "Please insert your second number choice between 1 and 100\n";

	cin >> secondnumber; //gets second number.

if (firstnumber > secondnumber) //if else statement to make sure firstnumber remains the smallest!
		{
			f = firstnumber;
			g = secondnumber;
			secondnumber = f;
			firstnumber = g;
		}
		else
		{
			a = firstnumber;
			b = secondnumber;
		}


		FunctionEVEN = firstnumber - secondnumber;  
		FunctionEVEN = FunctionEVEN/2;
		//This calculates the number of even numbers.
		
		if (FunctionEVEN < 0)
		{
			FunctionEVEN = FunctionEVEN * (-1);
		}
		else
		{
			FunctionEVEN = FunctionEVEN;
		}
		//if else statement to make sure FunctionEVEN is not a negative number.

		cout << "\nThere are " <<FunctionEVEN <<" even numbers between " << firstnumber << " and " << secondnumber << " \nHere they are:\n";
		//This will print the number of even numbers.


for(int x = firstnumber + 1; x <= secondnumber - 1; x++)  

	//Makes sure not to include the inputed numbers in the count.

	{
	if(0 == x % 2)
	{ 
		cout << x << endl; FunctionEVEN++; 
	} } 
//This will list all the even numbers.


return 0;

}
This question has already been answered. Start a new discussion instead.