tags:

views:

150

answers:

2

I need help making an c++ program with a function that uses int Disc(int A, int B, int C) and calculates returns B*B-4*A*C and use the function Disc in the program..... i have this so far.

void main(){
     cout << Disc(a,b,c);
}
+5  A: 

What does the book you are using say about functions?

Assuming you can't get a book, take a look that this tutorial on functions (See the edit below)

You already have the function definition. The name, what parameters it takes and what it returns so if you take some time looking at the above tutorial you should be able to put something together (All you need to do is to write the body of the function).

The one thing that may cause you an issue (compiler error) is if you don't put it above the main function as either the function definition or the function itself must come before it is used. For simplicity at this point I reccomend you just put the function itself above the main function as shown in first example in the tutorial I linked to.

EDIT about linked tutorial
It suggests you use return with brackets. Example:

return (5);

Where as it should be used without them. Example:

return 5;
Yacoby
Obsolete return syntax and namespaces in the same example?? Anyway, there must be a better tutorial
Ernelli
cool thanks for the help!
@Ernelli Ouch, I just noticed that. Any recommendations would be welcome.
Yacoby
@Yacoby, I noticed that it was the first result on google "C++ tutorial", I tried "good C++ tutorial" it was still first. Anyway, a real good C/C++ tutorial that could be to refered to would be nice. Any suggestions are welcome...
Ernelli
+3  A: 

Ok, so you define the function Disc then:

int Disc(int A, int B, int C) { /* tricky part goes here... */ }

Ernelli
Here's a hint: The *tricky part goes here* part is **already in your post**!