# turbo c++ user

• 07-08-2007
nampootah
turbo c++ user
hi everyone. im here to ask everyone's help. im a student, enrolled in a turbo c++ subject.

a.)

Write a function PerimeterMinusCenter that take in a two-dimensional array called intarr of 3 rows and 3 columns. The function sums the values in the perimeter of the array. It then returns the difference of this sum and the center value (the value in cell row 1,column 1).

For example, if
Code:

`intarr(3)(3) ={        {1,1,1},  {1,2,1},  {1,1,1}};`
PerimeterMinusCenter (intarr) returns 6 (1+1+1+1+1+1+1+1 - 2)).

b.)

Write a function Compare that take in a two-dimensional array called intarr of 3 rows and 3 columns. The function sums up separately the values in the diagonal of the array and the non-diagonal values. It then compares these two sums and return 1 if the diagonal sum is larger than the non-diagonal sum and 0 otherwise.

For example, if
Code:

`intarr(3)(3) ={        {1,2,2},        {2,1,2},        {2,2,1}};`
Compare (intarr) returns 0 (since (1+1+1) < (2+2+2+2+2+2)).

c.)

Write a recursive function called CountEvenASCII that takes in a string parameter str and return the number of characters with even ASCII codes. For example CountEvenASCII("ABCDE") returns 2 (as B and D are of even ASCII codes).

d.)

Change your solution above into an iterative solution.

:DHELP will be very much appreciated...thank you guys, i hope atleast one can help me out here...
• 07-08-2007
indigo0086
**** ***

write a program to decode what I just said.

I also have a feeling you are going to fail teh turbo C++
• 07-08-2007
nampootah
Quote:

Originally Posted by indigo0086
**** ***

write a program to decode what I just said.

I also have a feeling you are going to fail teh turbo C++

• 07-08-2007
Neo1
Quote:

Originally Posted by nampootah

Try and show us what you have done so far, what have you tried to solve the problem?
• 07-08-2007
anon
It doesn't help much to put your assignment in code tags (making it practically unreadable). Put the code you have in code tags.
• 07-08-2007
MacGyver
How about we work out a deal where you write me a deathray that can blow up entire cities and armies, has low recharge time, and is cheap to manufacture, and I'll pass your course for you?
• 07-11-2007
dwks
For a):
Summing the values located around the parameter of an array can be done with two for loops. The first loop goes horizontally and encompasses the top and bottom rows of the 2D array. The second goes vertically and does the left and the right -- but the second for loop has to start one down and end one up from the bottom, because the corners were already summed by the first for loop.

For b), you could sum the entire array as well as the diagonals. Then the non-diagonal sum could be calculated by total-diagonal.

Assuming that the array is "square" (the first dimension is the same as the second), diagonal calculation could be done in one for loop, or perhaps two. You'd use array[i][i] and array[i][max-i] or something.

For c), this might be of some use: http://faq.cprogramming.com/cgi-bin/...&id=1043284385