Hi,

I'm just trying out something with returning values to a variable and I've encountered a problem.

Basically the program is supposed to return the value of

string x

as either true or false from the

isEven

function, then the

void output

function should output the value of

string x

The problem is that at line 8, my IDE says,

ERROR: expected a declaration

The code :

#include "stdafx.h"
#include "stdio.h"
#include <iostream>


using namespace std;

	void output {
		cout << x;
		cin.get();
	}
	
	string IsEven(string x)
	{
		if ( 100 / 3 % 2 == 0 ) return "even";
		else return "odd";
	}

Recommended Answers

All 2 Replies

You need a pair of brackets even if you don't provide arguments for a function. ;)

Thank you very much. It worked!

void output () {
		cout << x;
		cin.get();
	}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.