Hello I am horrible in c++ and need help
my class is suppose to create a program that prints only even numbers between 2 integers entered from the keyboard
my prog is a train wreck please help
#include <iostream>
using namespace std;
int print_even (int a, int b)
{for (a=0; a<=b; a++);
{if (a%2!=0)
a= a+1;
}}
int main()
{int a, b;
cout<< "Enter Your Beginning and Ending numbers...."<< endl;
cin>> a, b;
the first misstake you did was putting ; infront of the for loop ; means that the statement ends,
do not try to initialize 2 variables in the same cin>>, the function is called print_even then print all your numbers in there and set the return type to void so it wont return anything, you assigned a in the loop the value 0 so it will start from 0 and up everytime.
edit: the modulo operator gives the rest of a division if the rest is 0 it's even so check for == 0
hope it helped :)