Just by reading, I see 4 errors here.
- You need to learn about
function prototype
- Array are not declared this way
int i,r[i];
- The function call and the function parameter do nit match
a[20]=area(r);
...
double area(int r[int i])
Solution 1 already gives you corrections. So 2 advices Learn debugger and learn properly C++.
-----
Use the debugger to see what your code is doing. It allow you to execute lines 1 by 1 and to inspect variables as it execute.
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.
Debugger - Wikipedia, the free encyclopedia[
^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[
^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
-----
Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[
^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[
^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[
^]
C++ Programing Language[
^]