i have declared two functions of void type.lets one function calculates value of variable 'c' and other of variable 'y' and when i cout them it comes out to be correct within the function.now i want to declare another function that compares values of 'c' and 'y' and return 1 if c=y and return 0 otherwise.please help and also i m a beginner in c++.

Change the return type of each function to return the value of c and y, then in the third function you can get those values to compare them. Something like this:

int foo1()
{
   int c = 5;
   return c;
}

int foo2()
{
   int y = 0;
   return y;
}

int foo3()
{
   int c = foo1();
   int y = foo2();
   return c == y;  // returns either 1 or 0 (true or false)
}

return 1 if c=y and return 0 otherwise

for this , you need to declare a function of int return type.

function that compares values of 'c' and 'y'

just use == operator.

if(c==y)
return 1;
else
return 0;

You might also do like this:

int foo1() {
    return 2;
}

int foo2() {
    return 2;
}

bool areEqual() {
    return foo1() == foo2();
}

It's worth to mention sequence points in C++, luckily it was on of my latest post on my blog:
http://blog.panqnik.pl/dev/sequence-points-in-c-cpp/

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.