functions

hi guys, im new here, anyone knows about this problem? the code is runnable but whenever i input data the display will says "DIFF IS 727" or any number before it will display the right answer, here is my code ,
any one who will help me for this problem is highly appreciated :)
(im using TC)

#include<iostream.h>
#include<conio.h>

void input();
int process(int x, int y);
void output();

int main()
{
clrscr();
input();
output();
getch();
}

void input()
{
int x, y, z;
cout<<"2 numbers please:";
cin>>x;
cin>>y;
z=process(x,y);
output();
getch();
}

int process(int x, int y)
{
return x-y;
}

void output()
{
int z;
cout<<"the diff is:"<<z;
getch();
}

thats all. .thank you :). i separated input from output so that it is easy to understand
Last edited on
The variable z in input is not the variable z in output.
Topic archived. No new replies allowed.