i have this worksheet to do and i get most of the stuff..except one question.
it asks "what's the difference between foo & foo1? how would u call foo1 and foo2 such that they both print 34?"
void foo()
{
int x=34;
cout<
}
int foo1()
{
int x=34;
return x;
}
ok so basically. i don't understand the second question of that question at all. the first part..i understand..one is void and one is int. but they both actually PRINT 34. so...i don't get it. i don't really understand "return" i just don't see a difference because they both print 34. one just has return and one is cout.
2007-03-09
16:14:25
·
3 answers
·
asked by
boom56
1
in
Computers & Internet
➔ Programming & Design
hmm stuck on the last problem also. it says "declare implement, and call a function 'middle' that prompts the user to enter a string, remove the 1st character if length is even then return the middle character."
ok so far...i have
string middle();
string a;
int main()
{
cout<<"Enter in a string"<
getline(cin,a);
if(a.length()%2==0)
a.erase(0,1);
a.length/2=b;
return b;
}
i know the a.length/2 is wrong..but..what i'm trying to figure out is how to get...the middle character to print.
i also still don't get return..what's the difference between return and cout
2007-03-09
16:22:39 ·
update #1