So I have a c++ final coming up next week and I still don't know if I have functions understood. take a look at some examples I made and see if they are correct.
[/font]
also i have trouble figuring the outputs of some functions like this one:
[/font]
what the frink is the output?
Thanks for any help.[/font]
[font=verdana,arial,helvetica]code:[/font]
void name ();
//returns name
int main()
{
name();
return 0;
}
void name()
string name = "buzzard34";
cout << name << endl;
[font=verdana, arial, helvetica]void name ();
//returns name
int main()
{
name();
return 0;
}
void name()
string name = "buzzard34";
cout << name << endl;
[/font]
[font=verdana,arial,helvetica]code:[/font]
int SumSquares (int x);
//contains 1 value parameter type int which is
//a 2 digit integer and returns sum of squares of digits of the value thats passed.
int main()
{
stuff
}
int SumSquares(int x)
{
int x,first,second;
cin >> x;
first = x/10;
second = x/10;
return = (sqrt(first)+sqrt(second))
}
example would be like 48; 4^2+8^2=80
[font=verdana, arial, helvetica]int SumSquares (int x);
//contains 1 value parameter type int which is
//a 2 digit integer and returns sum of squares of digits of the value thats passed.
int main()
{
stuff
}
int SumSquares(int x)
{
int x,first,second;
cin >> x;
first = x/10;
second = x/10;
return = (sqrt(first)+sqrt(second))
}
example would be like 48; 4^2+8^2=80
also i have trouble figuring the outputs of some functions like this one:
[/font]
[font=verdana,arial,helvetica]code:[/font]
void figure_me_out (int& a, int& b, int c);
int main()
{
int a,b,c;
a=10;
b=20;
c=30;
figure_me_out(a,b,c);
cout << a << " " << b << " " << c << endl;
a=10;
b=20;
c=30;
figure_me_out(c,a,b);
cout << a << " " << b << " " << c << endl;
a=10;
b=20;
c=30;
figure_me_out(b,b,b)
cout << a << " " << b << " " << c << endl;
return 0;
}
void figure_me_out (int& a, int& b, int c)
{
a=1; b=2; c=3;
}
[font=verdana, arial, helvetica]void figure_me_out (int& a, int& b, int c);
int main()
{
int a,b,c;
a=10;
b=20;
c=30;
figure_me_out(a,b,c);
cout << a << " " << b << " " << c << endl;
a=10;
b=20;
c=30;
figure_me_out(c,a,b);
cout << a << " " << b << " " << c << endl;
a=10;
b=20;
c=30;
figure_me_out(b,b,b)
cout << a << " " << b << " " << c << endl;
return 0;
}
void figure_me_out (int& a, int& b, int c)
{
a=1; b=2; c=3;
}
what the frink is the output?
Thanks for any help.[/font]