#include<iostream.h>
int tripeCallByValue(int count1)

void main(){
int count=2;
cout<<"count is "<<count<<endl;
cout<<"count1 is "<<count1;
}
int tripeCallByValue(int count1){
count1=count*3;
return count1;
}

when i compile with compiler,i got a syntax error.but i didnt where i have did worng.

line 10 should be count1 = count1 * 3

You're also missing a ';' after your prototype on Line 2. Also, while you're at it, you should change your main() to return-type int and add a return 0; at the end of the function.

This is where the whitespace lecture occurs.

Make better use of whitespace and your code will be easier to read. As written/posted, your code is a jumbled mess, I'm not surprised you can't see it.

Reformatted for readability demo (syntax errors not corrected):

#include<iostream.h>

int tripeCallByValue(int count1)

void main() {
  int count = 2;
  cout << "count is " << count << endl;
  cout << "count1 is " << count1;
}

int tripeCallByValue(int count1) {
  count1 = count * 3;
  return count1;
}

Do you see how much easier it is to see the elements of your code/syntax (operators, variables, etc.) when compared to your original code?

still got error.T^T,help pls.gonna crazy soon.

Hello sing1006,
You haven't initialized count1 in the main() and count can be used only in the main() (local scope).

Hello sing1006,
You haven't initialized count1 in the main() and count can be used only in the main() (local scope).

The question is like this.im not sure im doing right or wrong.
-Function tripleCallByValue that pass a copy of count call-by-value, triples the copy and return the new value.
In the question above,triples the copy means 2*2*2 or 2*3?
pls,help me.im begging u all.2moro the due date for this exercise.

Can you post the errors you got ?

Can you post the errors you got ?

Error E2451 x.cpp 7: Undefined symbol 'count1' in function main()
Error E2451 x.cpp 10: Undefined symbol 'count' in function tripeCallByValue(int)

That's what i said in my previous post. Count is bound to main() only you cannot use it elsewhere and count1 can be used in the tripecallbyvalue() function only. So you should modify the lines 7 and 8 like this..

cout<<"count is "<<count<<endl;
cout<< "count1 is " << tripeCallByValue(count);

and line 10 in the function tripeCallByValue() like this...

count1 = count1 * 3;

That's what i said in my previous post. Count is bound to main() only you cannot use it elsewhere and count1 can be used in the tripecallbyvalue() function only. So you should modify the lines 7 and 8 like this..

cout<<"count is "<<count<<endl;
cout<<"count1 is "<<tripeCallByValue(count);

and line 10 in the function tripeCallByValue() like this...

count1 = count1 * 3;

erm,i think i got it.
but can u help mee check is that the answer match to the question?
Function tripleCallByValue that pass a copy of count call-by-value, triples the copy and return the new value.

#include<iostream.h>
int tripleCallByValue(int);
void main(){
int count=2;
cout<<"count="<<count<<endl;
cout<<"Value returned by tripleCallByValue:"<<tripleCallByValue(count)<<endl;
}
int tripleCallByValue(int a){
return a*a*a;
}

It's not a*a*a i think. Triple means a * 3.

The result of [TEX]a*a*a[/TEX] is not a triple it's a cube [TEX](a^3)[/TEX], there is a huge difference. A triple is multiplication by the number 3.

Using 2 as an example value for 'a':
[TEX]2*2*2 = 2^3 = 8[/TEX] (this is a cube)
[TEX]2 * 3 = 6[/TEX] (this is a triple)

Using 10 as an example value:
[TEX]10*10*10 = 10^3 = 1,000[/TEX] (this is a cube)
[TEX]10 * 3 = 30[/TEX] (this is a triple)

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.