# Need help. Can't identify error.

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 07-04-2011
bummielove
Need help. Can't identify error.

Code:

#include <stdio.h>

int main()
{
int a, b, c, ans1, ans2, ans3, ans4, ans5;
printf("Think of three Real numbers... \n\n\n");
scanf("%d", &a);
scanf("%d", &b);
scanf("%d", &c);
ans1 = a*-(b+c);
ans2 = (b*b)-4(a*c);
ans3 = (a*a)+(b*b*b)+(c*c)-12;
ans4 = ((a+b)/(c-b))-(3(b*b))+((4(b))/(3(c)));
ans5 = 3(a*a)-2(b*b)-9.14;
printf("\nFor equation 1, we have the answer %d,\nFor equation 2, we have %d,\nFor equation 3, we have %d,\nFor equation 4, we have %d and,\nFor equation 5, we have %d, ", ans1, ans2, ans3, ans4, ans5);

return 0;
}

• 07-04-2011
ssharish2005
First of all you don’t have to print your message in just big front. We all here i believe can read with the normal font! And there is no necessity to print that with an annoying bold!

**With the normal font** Now tell us what excatly u'r having issues with? Rather than just saying there is a problem.

ssharish
• 07-04-2011
stahta01
"3(y)" is not right you need to do "3*(y)" instead.

Tim S.
• 07-04-2011
bummielove
When I'm trying to run the program, it keeps on displaying " error: called object 4 is not a function" There.
• 07-04-2011
bummielove
Quote:

Originally Posted by stahta01
"3(y)" is not right you need to do "3*(y)" instead.

Tim S.

Thanks! :)
• 07-04-2011
bummielove
Quote:

Originally Posted by ssharish2005
First of all you don’t have to print your message in just big front. We all here i believe can read with the normal font! And there is no necessity to print that with an annoying bold!

**With the normal font** Now tell us what excatly u'r having issues with? Rather than just saying there is a problem.

ssharish

When I'm trying to run the program, it keeps on displaying " error: called object 4 is not a function" There.
• 07-04-2011
AndrewHunter
Take a look at your equations:
Code:

ans1 = a*-(b+c);
ans2 = (b*b)-4(a*c);
ans3 = (a*a)+(b*b*b)+(c*c)-12;
ans4 = ((a+b)/(c-b))-(3(b*b))+((4(b))/(3(c)));
ans5 = 3(a*a)-2(b*b)-9.14;

Then take a look at what you were told:
Quote:

"3(y)" is not right you need to do "3*(y)" instead.
Tim S.
No apply this idea to all of your equations. C is not a calculator parser, it needs to be told exactly what you want it to do.
• 07-04-2011
bummielove
Quote:

Originally Posted by stahta01
"3(y)" is not right you need to do "3*(y)" instead.

Tim S.

That's what I needed! Thank you Tim S! \m/ Thanks! Thanks to those who helped me here! :)
• 07-04-2011
CommonTater

1) The most accepted form of main is.. int main (void) ... empty brackets signify "any parameters" where specifying void signals "no parameters".

2) You would do well to split your final printf() into multiple statements, perhaps one per calculation. The final result is the same but the code will be far easier to read.

3) Choosing more descriptive but not overly verbose variable names also helps readability of code. For example instead of a, b, c you could use FirstInput, SecondInput and ThirdInput ... again to make it easier to read and follow your code.

Other than the syntax errors pointed out by the others, I'd say you're off to a pretty good start.

One final tip... Turn the warning levels in your compiler all the way up and treat all reports as errors to be corrected. You'll be surprised how smart your compiler is about helping you write good code...
• 07-04-2011
bummielove
Quote:

Originally Posted by AndrewHunter
Take a look at your equations:
Code:

ans1 = a*-(b+c);
ans2 = (b*b)-4(a*c);
ans3 = (a*a)+(b*b*b)+(c*c)-12;
ans4 = ((a+b)/(c-b))-(3(b*b))+((4(b))/(3(c)));
ans5 = 3(a*a)-2(b*b)-9.14;

Then take a look at what you were told:

No apply this idea to all of your equations. C is not a calculator parser, it needs to be told exactly what you want it to do.

Thank You Sir!
• 07-04-2011
bummielove
Quote:

Originally Posted by CommonTater

1) The most accepted form of main is.. int main (void) ... empty brackets signify "any parameters" where specifying void signals "no parameters".

2) You would do well to split your final printf() into multiple statements, perhaps one per calculation. The final result is the same but the code will be far easier to read.

3) Choosing more descriptive but not overly verbose variable names also helps readability of code. For example instead of a, b, c you could use FirstInput, SecondInput and ThirdInput ... again to make it easier to read and follow your code.

Other than the syntax errors pointed out by the others, I'd say you're off to a pretty good start.

One final tip... Turn the warning levels in your compiler all the way up and treat all reports as errors to be corrected. You'll be surprised how smart our compiler is about helping you write good code...

Thank you for the tip! THAAAAAAAAANKS! :)
• 07-04-2011
laserlight
Quote:

Originally Posted by CommonTater
1) The most accepted form of main is.. int main (void) ... empty brackets signify "any parameters" where specifying void signals "no parameters".

Actually, the empty parentheses mean "no parameters" because this is a function definition. However, for many other functions, you will probably have a corresponding prototype, in which case the empty parentheses will indeed mean "any parameters", so you might as well be consistent.
• 07-04-2011
AndrewHunter
Quote:

Originally Posted by laserlight
Actually, the empty parentheses mean "no parameters" because this is a function definition. However, for many other functions, you will probably have a corresponding prototype, in which case the empty parentheses will indeed mean "any parameters", so you might as well be consistent.

In case you were curious Tater, per the standard section 6.7.5.3:
Quote:

14 An identifier list declares only the identifiers of the parameters of the function. An empty
list in a function declarator that is part of a definition of that function specifies that the
function has no parameters.
The empty list in a function declarator that is not part of a
definition of that function specifies that no information about the number or types of the
parameters is supplied.124)
I know I always try to look up these things up.
• 07-04-2011
stahta01
@AndrewHunter: When was that (standard section 6.7.5.3) change to standard approved?

Tim S.
• 07-04-2011
laserlight
Quote:

Originally Posted by stahta01
When was that (standard section 6.7.5.3) change to standard approved?

In 1999, but it is not really a change since the wording was retained from 1989.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last