Ok here is my question. How do you make subroutine things, and how do you pass the variables so you can use them in different subroutines? Ok, the following is an example that illustrates using subroutines/functions, and it is in need of variables being passed/parameters. Even though I could easily do it without the subroutines, I did it like this so I get how to do it. I made it so things need to be passed from subroutine to subroutine, main to subroutine, and subroutine to main. Could someone please copy this code and make all necessary changes (like variable passing and correct use of subroutines/functions) to make it work? Thanks, this would help me a lot and I could finally fix my awesome program.
void func1(); //Do I need to do this? Prototype?
void func2(); //Same thing...?
void func3();
void func4();
int main()
{
int aa, ab, ac;
func1();
p=99;
func2();
func3();
cout<<x<<y<<z;
cout<<a<<b<<c;
int gx=sum2*5
func4();
cout<<gh;
cout<<cd;
cout<<ab;
return 0;
}
//FUNCTION DEFINITIONS
void func1() //Function definition? Must I do this?
{
int x, y, z, p;
x=56;
y=34;
z=2;
}
void func2()
{
int gh=p+x+z;
aa=45;
int sum=x+y+z;
char a='hello user' // <-- Is that the right type of quotes?
int b=99;
int c=10;
sum1=b+c;
}
void func3()
{
ab=55;
cout<<sum<<a<<x;
int sum2=sum+sum1;
}
void func4()
{
ac=ab+aa;
cout<<gx<<a<<x<<sum1;
int cd=70;
gh=gh*2;
}



LinkBack URL
About LinkBacks


