开发者

C++ help and questions

开发者 https://www.devze.com 2022-12-24 17:30 出处:网络
I need help making an c++ program with a function that uses int Disc(int A, int B, int C) and calculates return开发者_JAVA技巧s B*B-4*A*C and use the function Disc in the program..... i have this so f

I need help making an c++ program with a function that uses int Disc(int A, int B, int C) and calculates return开发者_JAVA技巧s 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);
}


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;


Ok, so you define the function Disc then:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号