By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,943 Members | 1,260 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,943 IT Pros & Developers. It's quick & easy.

perimeter of a triangle

P: n/a

Hello,

Here is my code of a perimeter of a triangle such as:
2
1 7
3 6 8
4 2 5 3


#include <iostream>
using namespace std;
int perimeterSum (int[][]A, int Size);
int main()

}
int perimeterSum(int[][]A, int size){

int sum = 0;
// the left-hand side (the first column)
for (int i = 0; i < size; i++)
sum += A[i][0];
// the bottom row, except the first element
for (int i = 1; i < size; i++)
sum += A[A.length - 1][i];
// the diagonal except the first and last elements
for (int i = 1; i < size - 1; i++)
sum += A[i][i];
return sum;

}
}
i am only on chapter 3 so the code needs to be very basic using:

int perimeterSum (int[][] A, int Size) {
int sum = 0;
I tried this code but i got 4 errors in visual c++.
What am I doing wrong?

Thank you

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Ian
NJ*****@gmail.com wrote:

I tried this code but i got 4 errors in visual c++.


Then post them!

Ian
Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.