Help with passing a variable by reference

I am trying to pass a user inputted number to a void method by reference and adding 2 if even and 5 if odd. I am getting the following errors on line 23 expression must be a modifiable lvalue and '=': left operand must be l-value .


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Variable by Reference.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include "pch.h"
#include <iostream>
using namespace std;

void oddeven(int&);
int main()
{
	int num{ 0 };
	cout << "Enter a Number.\n";
	cin >> num;
	oddeven(num);
	cout << "\nNew number is " << num;

	
}
void oddeven(int &num)
{

	cout << "check 1";
	if ((num % 2)=0 )
	{
		num += 2;
		cout << "check 2";
		return;
	}
	
	else
		num += 5;
	cout << "check 3";
	return;
	
}
= is used for assignments.
== is used for comparisons.
Thank you for the help it's working!!!
Topic archived. No new replies allowed.