# Need help. Can't identify error.

This is a discussion on Need help. Can't identify error. within the C Programming forums, part of the General Programming Boards category; Beginner here. This is the first program I made. There seems to be an error. Please help me fix it. ...

1. ## Need help. Can't identify error.

Beginner here. This is the first program I made. There seems to be an error. Please help me fix it. Thanks.

Code:
```#include <stdio.h>

int main()
{
int a, b, c, ans1, ans2, ans3, ans4, ans5;
printf("Think of three Real numbers... \n\n\n");
printf("Enter your first number\n");
scanf("%d", &a);
printf("Enter your second number\n");
scanf("%d", &b);
printf("Enter your third number\n");
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;
}```

2. 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

3. "3(y)" is not right you need to do "3*(y)" instead.

Tim S.

4. When I'm trying to run the program, it keeps on displaying " error: called object 4 is not a function" There.

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

Tim S.
Thanks!

6. 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.

7. 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:
"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.

8. 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!

9. Minor issues about readable code...

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...

10. 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!

11. Originally Posted by CommonTater
Minor issues about readble code...

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!

12. 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.

13. 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:
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.

14. @AndrewHunter: When was that (standard section 6.7.5.3) change to standard approved?

Tim S.

15. 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.

Page 1 of 2 12 Last
Popular pages Recent additions